2016-05-18 36 views
2

我在Android Studio中制作一个简单的布局是这样的:滚动型不能显示的最后一个元素

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    tools:context="hisoka.poipo.com.wishtleblower.KorupsiActivity" 
    android:scrollIndicators="right" 
    android:fillViewport="true" 
    android:layout_weight="1" 
    > 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 
     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="#F0FFFF" 
      android:layout_marginTop="@dimen/topMargin" 
      android:layout_marginBottom="@dimen/bottomMargin" 
      android:layout_marginLeft="@dimen/leftMargin" 
      android:layout_marginRight="@dimen/rightMargin" 
      android:orientation="vertical"> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Keterangan :" 
      android:textStyle="bold" 
      android:layout_centerInParent="true"/> 

      <EditText 
       android:layout_width="match_parent" 
       android:layout_height="60dp" 
       android:inputType="textMultiLine" 
       android:ems="10" 
       android:background="@drawable/box" 
       android:id="@+id/ket_et" /> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="#B0E0E6" 
      android:layout_marginTop="@dimen/topMargin" 
      android:layout_marginBottom="@dimen/bottomMargin" 
      android:layout_marginLeft="@dimen/leftMargin" 
      android:layout_marginRight="@dimen/rightMargin" 
      android:orientation="vertical"> 
      <TextView 
       android:layout_height="wrap_content" 
       android:layout_width="wrap_content" 
       android:text="Terduga :" 
       android:layout_weight="1" 
       android:textStyle="bold" 
       android:layout_margin="4dip" 
       /> 

      <TextView 
       android:layout_height="wrap_content" 
       android:fontFamily="sans-serif" 
       android:text="Nama :" 
       android:layout_weight="1" 
       android:layout_margin="4dip" 
       android:layout_width="wrap_content" 
       /> 
      <EditText 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:background="@drawable/box" 
       android:layout_margin="4dip" 
       android:layout_width="match_parent" 
       /> 

      <TextView 
       android:layout_height="wrap_content" 
       android:fontFamily="sans-serif" 
       android:text="Jabatan :" 
       android:layout_weight="1" 
       android:layout_margin="4dip" 
       android:layout_width="wrap_content" 
       /> 
      <EditText 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:background="@drawable/box" 
       android:layout_margin="4dip" 
       android:layout_width="match_parent" 
       /> 

      <TextView 
       android:gravity="center_vertical" 
       android:text="Klasifikasi Jabatan :" 
       android:layout_height="wrap_content" 
       android:fontFamily="sans-serif" 
       android:layout_margin="4dip" 
       android:layout_weight="1" 
       android:layout_width="wrap_content" 
       /> 

       <Spinner 
        android:id="@+id/korupsiSpinnera" 
        android:layout_weight="1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" /> 

       <TextView 
        android:layout_height="wrap_content" 
        android:fontFamily="sans-serif" 
        android:text="Nama :" 
        android:layout_weight="1" 
        android:layout_margin="4dip" 
        android:layout_width="wrap_content" 
        /> 
      <EditText 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:background="@drawable/box" 
       android:layout_margin="4dip" 
       android:layout_width="match_parent" 
       /> 
       <TextView 
        android:layout_height="wrap_content" 
        android:fontFamily="sans-serif" 
        android:text="Jabatan :" 
        android:layout_weight="1" 
        android:layout_margin="4dip" 
        android:layout_width="wrap_content" 
        /> 
      <EditText 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:background="@drawable/box" 
       android:layout_margin="4dip" 
       android:layout_width="match_parent" 
       /> 

       <TextView 
        android:gravity="center_vertical" 
        android:text="Klasifikasi Jabatan :" 
        android:layout_height="wrap_content" 
        android:fontFamily="sans-serif" 
        android:layout_margin="4dip" 
        android:layout_weight="1" 
        android:layout_width="wrap_content" 
        /> 
       <Spinner 
        android:id="@+id/korupsiSpinnerb" 
        android:layout_weight="1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" /> 
     </LinearLayout> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="#B0E0E6" 
     android:layout_marginTop="@dimen/topMargin" 

     android:layout_marginLeft="@dimen/leftMargin" 
     android:layout_marginRight="@dimen/rightMargin" 
     android:orientation="vertical"> 
     <TextView 
      android:gravity="center_vertical" 
      android:text="Lampiran :" 
      android:textStyle="bold" 
      android:layout_height="wrap_content" 
      android:fontFamily="sans-serif" 
      android:layout_margin="4dip" 
      android:layout_weight="1" 
      android:layout_width="wrap_content" 
      /> 
     <TextView 
      android:gravity="center_vertical" 
      android:text="Nama File " 
      android:textStyle="bold" 
      android:layout_height="wrap_content" 
      android:fontFamily="sans-serif" 
      android:layout_margin="4dip" 
      android:layout_weight="1" 
      android:layout_width="wrap_content" 
      /> 
     <TextView 
      android:gravity="center_vertical" 
      android:text="Rfounder " 
      android:textStyle="bold" 
      android:layout_height="wrap_content" 
      android:fontFamily="sans-serif" 
      android:layout_margin="4dip" 
      android:layout_weight="1" 
      android:layout_width="wrap_content" 
      /> 
     <TextView 
      android:gravity="center_vertical" 
      android:text="Keterangan " 
      android:textStyle="bold" 
      android:layout_height="wrap_content" 
      android:fontFamily="sans-serif" 
      android:layout_margin="4dip" 
      android:layout_weight="1" 
      android:layout_width="wrap_content" 
      /> 
     <TextView 
      android:gravity="center_vertical" 
      android:text="CEO " 
      android:textStyle="bold" 
      android:layout_height="wrap_content" 
      android:fontFamily="sans-serif" 
      android:layout_margin="4dip" 
      android:layout_weight="1" 
      android:layout_width="wrap_content" 
      /> 
     <TextView 
      android:gravity="center_vertical" 
      android:text="Size " 
      android:textStyle="bold" 
      android:layout_height="wrap_content" 
      android:fontFamily="sans-serif" 
      android:layout_margin="4dip" 
      android:layout_weight="1" 
      android:layout_width="wrap_content" 
      /> 
     <TextView 
      android:gravity="center_vertical" 
      android:text="36 KB " 
      android:textStyle="bold" 
      android:layout_height="wrap_content" 
      android:fontFamily="sans-serif" 
      android:layout_margin="4dip" 
      android:layout_weight="1" 
      android:layout_width="wrap_content" 
      /> 
     <TextView 
      android:gravity="center_vertical" 
      android:text="Delete " 
      android:textStyle="bold" 
      android:layout_height="wrap_content" 
      android:fontFamily="sans-serif" 
      android:layout_margin="4dip" 
      android:layout_weight="1" 
      android:layout_width="wrap_content" 
      /> 
     <TextView 
      android:gravity="center_vertical" 
      android:text="X" 
      android:textStyle="bold" 
      android:layout_height="wrap_content" 
      android:fontFamily="sans-serif" 
      android:layout_margin="4dip" 
      android:layout_weight="1" 
      android:layout_width="wrap_content" 
      /> 
     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="end" 
      android:text="Add File" 
      /> 
     </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="#B0E0E6" 
     android:layout_marginTop="@dimen/topMargin" 
     android:layout_marginBottom="@dimen/bottomMargin" 
     android:layout_marginLeft="@dimen/leftMargin" 
     android:layout_marginRight="@dimen/rightMargin" 
     android:gravity="bottom" 
     android:orientation="vertical"> 
     <TextView 
      android:gravity="center_vertical" 
      android:text="Kirim Laporan" 
      android:textStyle="bold" 
      android:layout_height="wrap_content" 
      android:fontFamily="sans-serif" 
      android:layout_margin="4dip" 
      android:layout_weight="1" 
      android:layout_width="wrap_content" 
      /> 
     <TextView 
      android:gravity="center_vertical" 
      android:text="Captcha" 
      android:textStyle="bold" 
      android:layout_height="wrap_content" 
      android:fontFamily="sans-serif-condensed" 
      android:layout_margin="4dip" 
      android:layout_weight="1" 
      android:layout_width="wrap_content" 
      /> 
     <EditText 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:background="@drawable/box" 
      android:layout_margin="4dip" 
      android:layout_width="wrap_content" 
      android:ems="7" 
      /> 
     <CheckBox 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="New CheckBox" 
      android:id="@+id/checkBox" 
      android:layout_weight="1" /> 
     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="end" 
      android:text="Submit" 
      android:gravity="bottom" 
      /> 
    </LinearLayout> 

    </LinearLayout> 

</ScrollView> 

在Android Studio中,我可以看到就在那里,去年元素,如下图所示: preview in android studio 但是,当我我真正的设备上运行它,最后一个元素不能正常显示,我的最后一个按钮丢失: real device 我瞪大眼睛了一些网页,并表示只需添加

android:fillViewport="true" 

scrolView ..但这不能解决我的问题....我已经添加了另一个XML标签,但仍然没有... 任何想法...... ????

非常感谢你...... :)

+0

尝试删除android:layout_gravity =结束我认为它不需要 – Jois

+1

尝试给填充滚动视图到底部... –

+0

我需要layout_gravity =结束先生Jois ... :) –

回答

7

谢谢呃先生的建议。阿俊,我终于得到了答案......我把这个

android:paddingBottom="57dp" 

以滚动型...和它的固定... :)

enter image description here

+1

欢迎.... @Hyosoka Poipo –

+0

谢谢ehehe .. :) –

+0

即使它的一个黑客...搜索1小时后,它唯一的工作对我来说:P –

1

我觉得你使用AppbarLayout如果这样的话你应该使用NestedScrollVoew

只是你ScrollView这个

<android.support.v4.widget.NestedScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 
更换0
+0

Ooowh ... mmmm ...我还没试过NestedScrollView ...但谢谢你的回答先生。安德斯... :) –

+0

你的欢迎,添加填充底部是不是一个恰当的解决方案只是一个黑客,为底部添加额外的空间,所以空间将解除你的按钮 – Max

+0

Yaaps ....额外的空间只是为了抬起我的按钮ehehe ...:D –

相关问题