2017-06-14 2 views
0

Ich habe einen Bildschirm enthalten collapsable Symbolleiste (AppBarLayout) und scrollbaren Inhalt mit NestedScrollviewsInhalt innerhalb NestedScrollview nach unten gedrückt wird

Mein Haupt Layout:

<android.support.design.widget.CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

<android.support.design.widget.AppBarLayout 
     android:id="@+id/appbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:theme="@style/ToolbarTheme" 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/actionBarHeight" 
     android:background="@color/colorPrimary" 
     app:layout_scrollFlags="scroll|enterAlways" 
     app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> 

    </android.support.design.widget.AppBarLayout> 

    <android.support.v4.widget.NestedScrollView 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fillViewport="true" 
     android:scrollbars="none" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 
    <FrameLayout 
     android:id="@+id/layoutMainContent" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 
    </android.support.v4.widget.NestedScrollView> 

    </android.support.design.widget.CoordinatorLayout> 

Und das Layout Inhalte, die ich in FrameLayout layoutMainContent gesetzt ist wie unten

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
android:background="@color/colorBackground"> 

<LinearLayout 
    android:id="@+id/layoutAbout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:layout_centerInParent="true"> 
    <ImageView 
     android:id="@+id/ivLogo" 
     android:layout_width="100dp" 
     android:layout_height="100dp" 
     android:layout_gravity="center_horizontal" 
     android:src="@drawable/logo"/> 
</LinearLayout> 

<TextView 
    android:id="@+id/tvViewDetail" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:textColor="@color/colorPrimary" 
    android:text="@string/see_license" 
    android:gravity="center_horizontal"/> 
</RelativeLayout> 

Was ich will, ist das logo Bild in der Mitte ist und das Textview (tvViewDetail) ist am unteren Rand der auf dem Bildschirm. Das Logo befindet sich jedoch nicht in der Mitte (etwas nach unten gedrückt) und tvViewDetail wird aus dem Bildschirm geschoben.

Gibt es irgendetwas, was ich falsch gemacht habe? Jeder Vorschlag wäre hilfreich! Vielen Dank allen Meistern,

Antwort

0

Versuchen Sie, wie ich hoffe, es hilft.

<RelativeLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@color/colorBackground"> 

     <LinearLayout 
       android:id="@+id/layoutAbout" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:orientation="vertical" 
       android:gravity="center" 
       android:layout_centerInParent="true"> 
        <ImageView 
         android:id="@+id/ivLogo" 
         android:layout_width="100dp" 
         android:layout_height="100dp" 
         android:src="@drawable/logo"/> 

        <TextView 
         android:id="@+id/tvViewDetail" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:textColor="@color/colorPrimary" 
         android:text="@string/see_license"/> 
       </LinearLayout> 


       </RelativeLayout> 

daher Linearlayout Höhe und Breite werden wrap_content werden und die Schwerkraft wird Zentrum sein, so dass alle Kinder dieses linearen Layouts in der Mitte des linearen Layouts sein. und lineares Layout erscheinen auch in der Mitte des relativen Layouts.

Verwandte Themen