2016-11-03 2 views
1

eine erweiterte Symbolleiste in Android erstellen Ich versuche, eine Symbolleiste in Android zu erstellen, die 2x in Höhe der normalen Symbolleiste ist, und ein EditText in dem unteren Hälfte Abschnitt aufweist.Wie mit einem EditText am unteren

Derzeit habe ich den XML-Code (beachten Sie die android:layout_height="128dp"):

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:title="Messages" 
      android:titleTextColor="@color/windowBackground" 
      android:background="@color/buttonBackground" 
      android:layout_height="128dp"  
      android:layout_width="match_parent" 
      android:minHeight="?android:attr/actionBarSize" 
      android:gravity="bottom" /> 

     <fragment 
      android:id="@+id/no_activity_fragment" 
      class="com.ohmd.ohmd.ui.main.MainActivityListFragment" 
      android:name="com.ohmd.ohmd.ui.main.MainActivityListFragment" 
      android:layout_below="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="fill_parent"/> 

</RelativeLayout> 

Dies ist, wie es aussieht (ohne EditText noch): enter image description here

So ein paar Probleme, die ich m aufgeklebt:

  • (a) Wie kann ich die „Messa bekommen Wenn die Höhe auf "?android:attr/actionBarSize" eingestellt ist?

  • (b) Aftter den Titel nach oben bewegt, wie kann ich eine EditText Ansicht in der unteren Hälfte hinzufügen?

Dies ist, was ich hoffe, acheive: Nun enter image description here

Antwort

0

G ot it mit:

<android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:title="Messages" 
     android:titleTextColor="@color/windowBackground" 
     android:background="@color/buttonBackground" 
     android:layout_width="match_parent" 
     android:layout_height="?android:attr/actionBarSize" 
     android:gravity="center" /> 

    <RelativeLayout 
     android:orientation="vertical" 
     android:background="@color/buttonBackground" 
     android:layout_height="?android:attr/actionBarSize" 
     android:layout_below="@+id/toolbar" 
     android:id="@+id/card_view" 
     android:layout_width="match_parent" 
     android:gravity="center"> 

      <EditText 
       android:layout_margin="10dp" 
       android:id="@+id/tvSection" 
       android:background="@color/buttonBackgroundSelected" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_gravity="center" 
       android:gravity="center"/> 

    </RelativeLayout> 
0

, Sie könnten versuchen, die Symbolleiste Schwerkraft

android:gravity="top" 

Ändern Wenn das nicht funktioniert, könnten Sie loswerden der "title" und fügen ein TextView der Symbolleiste wie folgt hinzu:

<android.support.v7.widget.Toolbar 
    android:layout_width="match_parent" 
    android:layout_height="128dp" 
    android:background="@color/buttonBackground" 
    android:gravity="top" 
    android:minHeight="?android:attr/actionBarSize" 
    android:titleTextColor="@color/windowBackground"/> 

    <TextView 
     android:id="@+id/button_save" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="top|left" 
     android:text="Messages" 
     android:textColor="@color/buttonBackground"/> 

</android.support.v7.widget.Toolbar> 
Verwandte Themen