2016-08-23 4 views
0

Ich versuche, eine Schaltfläche (oder Schaltflächen) am unteren Rand der Ansicht und alles andere in einer Bildlaufansicht zu haben.Feste Schaltfläche am unteren Rand der Ansicht

Was immer ich mache, ich kann immer noch nicht die Schaltfläche unten (das gelbe Rechteck an der Unterseite des Bildes) haben, ich verstehe nicht genau warum.

Hier ist der Code:

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

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      app:layout_scrollFlags="scroll|enterAlways" 
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> 


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

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

     <TextView 
      android:id="@+id/txt_title" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@color/light_rose" 
      android:padding="20dp" 
      android:text="Contact" 
      android:textColor="@android:color/white" 
      android:textSize="30dp" /> 

     <ScrollView 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_above="@+id/footer" 
      android:layout_below="@+id/txt_title" 
      android:background="#0000ff" 
      android:fillViewport="true"> 

      <TextView 
       android:id="@+id/texthere" 
       android:layout_width="160dp" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_horizontal" 
       android:gravity="center_vertical|center_horizontal" 
       android:text="test test test test test test test test test test 
     test test test test test test test test test test test test test 
     test test test test test test test test test test test test test" 
       android:textSize="35sp"></TextView> 

     </ScrollView> 

     <RelativeLayout 
      android:id="@+id/footer" 
      android:layout_width="match_parent" 
      android:layout_height="100dp" 
      android:layout_alignParentBottom="true" 
      android:background="#ffff00"> 

      <TextView 
       android:id="@+id/texthere2" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerHorizontal="true" 
       android:layout_centerVertical="true" 
       android:text="things in your footer here" 
       android:textSize="20sp" /> 

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

siehe Screenshot:

enter image description here

Kann mir jemand einen Hinweis geben?

Antwort

0

Anstatt eine Schaltfläche am unteren Rand Ihrer Ansicht zu fixieren, verwenden Sie einfach die untere Navigationsleiste. Es ist attraktiver und attraktiver. Sie müssen die unteren Tabs auf WhatsApp, Facebook und Linkedin usw. Apps gesehen haben. Es ist einfach so und es ist auch ziemlich einfach.

Folgen Sie einfach den Link an https://github.com/roughike/BottomBar

oder wenn Sie i teilen Code arbeiten mit Ihnen können wollen. Viel Glück.

+1

Muchas Gracias. dies ersparte mir eine Menge Ärger – abdelghani

+0

froh, dass ich helfen konnte. –

0

ändern android:layout_height="wrap_content" zu android:layout_height="match_parent" im äußeren RelativeLayout

EDIT: und dann würde ich die Toolbar in der RelativeLayout umfasst.

+0

thx Sie, Ihre Antwort half mir, einige Details zu verstehen, die ich nicht bewusst war. – abdelghani

Verwandte Themen