1

Ich habe benutzerdefinierte Symbolleiste und ich möchte meine Listview unter Toolbar sein. Aber ListView erscheint auf der Symbolleiste und mein Layout_unterhalb funktioniert nicht. Ich weiß, dass viele Fragen schon einmal gestellt wurden. Aber nichts funktioniert. Bitte helfen Sie mirLayout_below funktioniert nicht in meinem Listenansicht

unten ist mein layoutxml

<?xml version="1.0" encoding="utf-8"?> 
<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" 

tools:context="faisal.home.com.tafaqquhfiddin.DuwaListView"> 

<include 
    layout="@layout/toolbar_layout" 
    /> 

<ListView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/MyListView" 
    android:layout_below="@+id/toolbar" 
    ></ListView> 

</RelativeLayout> 

toolbarlayout.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<android.support.v7.widget.Toolbar  
xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/toolbar" 
    android:layout_width="match_parent" 
    android:layout_height="?attr/actionBarSize" 
    android:background="@color/orange" 
    app:layout_scrollFlags="scroll|enterAlways" 
    app:titleTextColor="@color/white"></android.support.v7.widget.Toolbar> 

</LinearLayout> 
+0

Das Problem ist, weil Ihr lineare Anordnung auf toolbarlayout.xml die ganze Höhe des Bildschirms nimmt, weil Sie es als Spiel Elternteil angeben – HendraWD

Antwort

2

Frage wurde bereits von anderen Nutzern beantwortet ...

Ich mag nur mehr Informationen hinzuzufügen.

Ihr Layout kann viel einfacher sein. Sie brauchen keine Verwendung RelativeLayout. Verwenden Sie stattdessen einen LinearLayout mit android:orientation="vertical". Auf diese Weise werden Sie haben:

layout.xml

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    tools:context="faisal.home.com.tafaqquhfiddin.DuwaListView"> 

    <include 
     layout="@layout/toolbar_layout"/> 

    <ListView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/MyListView" /> 

</LinearLayout> 

Toolbar-Layout

<android.support.v7.widget.Toolbar 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/toolbar" 
    android:layout_width="match_parent" 
    android:layout_height="?attr/actionBarSize" 
    app:layout_scrollFlags="scroll|enterAlways" 
    android:background="@color/orange" 
    app:titleTextColor="@color/white" /> 
+0

können Sie mir helfen auf dies [link] (http://stackoverflow.com/questions/38687159/what-is-metadata-and-what-is-the-use-of-it-in-android) – FaisalAhmed

+0

@FaisalAhmed Fertig :) – W0rmH0le

+0

hilf mir noch einmal bitte http://stackoverflow.com/questions/38854909/can-fonts-and-its-size-can-be-changed-from-xml-in-android – FaisalAhmed

1

die LinearLayout von Ihrem toolbarlayout.xml entfernen. So Ihr toolbarlayout.xml soll wie folgt aussehen:

<android.support.v7.widget.Toolbar  
xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/toolbar" 
    android:layout_width="match_parent" 
    android:layout_height="?attr/actionBarSize" 
    android:background="@color/orange" 
    app:layout_scrollFlags="scroll|enterAlways" 
    app:titleTextColor="@color/white"></android.support.v7.widget.Toolbar> 
0

Verwenden Sie den folgenden Code wird es funktionieren.

mein layoutxml

<?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout 
    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:orientation="vertical" 
    tools:context="faisal.home.com.tafaqquhfiddin.DuwaListView"> 

    <include 
     layout="@layout/toolbar_layout" 
     /> 

    <ListView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/MyListView" 
     android:layout_below="@+id/toolbar" 
     ></ListView> 

</LinearLayout > 
0

Die Wurzel Layout toolbarlayout.xml Höhe ist "match_parent" ändern zu "wrap_content". Verwenden Sie den folgenden Code, der funktioniert.

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
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:orientation="vertical" 
tools:context="faisal.home.com.tafaqquhfiddin.DuwaListView"> 

<include 
    layout="@layout/toolbar_layout"/> 

<ListView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/MyListView" 
    android:layout_below="@+id/toolbar"/> 
</LinearLayout> 

toolbarlayout.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" android:layout_width="match_parent" 
android:layout_height="wrap_content"> 

<android.support.v7.widget.Toolbar  
xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/toolbar" 
    android:layout_width="match_parent" 
    android:layout_height="?attr/actionBarSize" 
    android:background="@color/orange" 
    app:layout_scrollFlags="scroll|enterAlways" 
    app:titleTextColor="@color/white"/> 

</LinearLayout>