Layout:Kopfleiste, Leiste unterer Rand, dazwischen Viewgroup für Bitmap

  • Antworten:3
  • Bentwortet
Wicki11
  • Forum-Beiträge: 103

22.03.2016, 16:05:22 via Website

Hallo,
ich möchte folgendes Layout haben:

  1. Kopfleiste mit TextViews (links, Mitte, rechts)
  2. Unterer Rand ebenso
  3. dazwischen soll der gesamte Platz für eine Viewgroup freigehalten werden in die eine im Programm erzeugte Bitmap eingefügt wird
<?xml version="1.0" encoding="utf-8"?>
  <RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background"
    xmlns:android="http://schemas.android.com/apk/res/android">
  <LinearLayout
      android:id="@+id/lin1"
      android:orientation="horizontal"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_alignParentStart="true"
      android:layout_alignParentLeft="true">

      <TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="New 1 Text"
          android:layout_gravity="left|top"
          android:id="@+id/textView1"/>
      <TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="New 2 Text"
          android:id="@+id/textView1a"
          android:layout_gravity="right|top"/>
  </LinearLayout>
  <LinearLayout
      android:orientation="horizontal"
      android:layout_below="@id/lin1"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:layout_alignParentleft="true"
      >
      <TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="New 3 Text"
          android:id="@+id/textView2"/>
  </LinearLayout>
      <FrameLayout
          android:id="@+id/fin1"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:layout_below="@id/lin1">
      </FrameLayout>
</RelativeLayout>

Es gelingt mir nicht:
die beiden TextViews der Kopfleiste nach links und rechts zu positionieren,
das 2. LinearLayout an den unteren Rand des RelativeLayout zu positionieren,
um einen Freiraum für das FrameLayout zu gewinnen

Bitte um Hinweise wieich das Problem lösen kann.

Gruß Wicki

Antworten
Pascal P.
  • Admin
  • Forum-Beiträge: 11.286

22.03.2016, 17:42:05 via Website

Du musst das FrameLaoyut unter die Kopfzeile mit layout_below wie du es schon hast, und mit layout_above über die Fußzeile. Damit ist das klar zwischen beiden definiert.

Und bei den Textview, weiss ich gerade auch nicht auswendig, ich würde mal die Gravity wegnemhmen.

Wie sieht das denn aus? Sind beide Views untereinander oder ineinander?

LG Pascal //It's not a bug, it's a feature. :) ;)

Wicki11

Antworten
Wicki11
  • Forum-Beiträge: 103

23.03.2016, 10:43:20 via Website

Inzwischen habe ich eine Lösung gefunden. Hier ist die aktuelle xml-Datei:

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background"
xmlns:android="http://schemas.android.com/apk/res/android">

<LinearLayout
    android:id="@+id/lin1"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentStart="true"
    android:layout_alignParentLeft="true">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="000000"
        android:id="@+id/points"
        android:layout_gravity="left|top"
        android:textColor="@color/points" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="000000"
        android:id="@+id/highscore"
        android:layout_gravity="center|top"
        android:textColor="@color/highscore"
        android:paddingLeft="30dp"
        android:paddingRight="30dp"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="0"
        android:id="@+id/round"
        android:textColor="@color/round"
        android:paddingLeft="30dp"
        />
</LinearLayout>
<FrameLayout
    android:id="@+id/container"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_below="@id/lin1"
    >
</FrameLayout>
<FrameLayout
    android:id="@+id/lin2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    >
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="00000"
        android:id="@+id/countdown"
        android:layout_gravity="center_horizontal|bottom"
        android:textColor="@color/points" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="\?"
        android:id="@+id/help"
        android:layout_gravity="left|bottom"
        android:background="@drawable/button"
        android:textColor="@color/title" />
    <Spinner
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="level"
        android:id="@+id/level"
        android:entries="@array/spinner_daten"
        android:prompt="@string/spinner_titel"
        android:layout_gravity="right|bottom"
        android:background="@drawable/button"
        android:textColor="@color/title" />
  </FrameLayout>

</RelativeLayout>

Das 1. FrameLayout ist für die Bitmap vorgesehen, das 2. für den Footer am unteren Rand.

Gruß Wicki

Antworten
Pascal P.
  • Admin
  • Forum-Beiträge: 11.286

23.03.2016, 12:45:57 via App

Hallo Wicki11!

Super, wenn deine Frage geklärt ist, setze doch bitte noch deinen Thread auf "Beantwortet"!

LG Pascal //It's not a bug, it's a feature. :) ;)

Antworten