我遇到了Android手机有问题,底部操作栏中的应用程序屏幕被手机中的操作栏切断了。请参阅下面的截图,其中更好地描述了我的问题。该按钮被操作栏切断。
下面是我的布局xml文件。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/main_bg"
tools:context="com.myapp.SeatsActivity">
<RelativeLayout
android:id="@+id/actionbar_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/irctc_actionbar_height"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageView4"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerVertical="true"
android:layout_marginLeft="6dp"
android:onClick="onClickgoHome"
android:src="@mipmap/iconhome" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="4dp"
android:layout_toLeftOf="@+id/button11"
android:layout_toRightOf="@+id/imageView4"
android:gravity="center"
android:text="SEAT AVAILABILITY"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/white"
android:textStyle="bold" />
<ImageView
android:id="@+id/imageView5"
android:layout_width="@dimen/irctc_actionbar_height"
android:layout_height="@dimen/irctc_actionbar_height"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="@drawable/trans_button"
android:clickable="true"
android:onClick="onClickShare"
android:padding="4dp"
android:scaleType="fitCenter"
android:src="@mipmap/share" />
<Button
android:id="@+id/button11"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/imageView5"
android:onClick="onClickDate"
android:text="date:"
android:textColor="@color/white" />
</RelativeLayout>
<LinearLayout
android:id="@+id/horizontal_line"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/actionbar_layout"
android:background="@color/white"
android:orientation="vertical" />
<TextView
android:id="@+id/txtview_trainname"
android:layout_width="match_parent"
android:layout_height="36dp"
android:layout_below="@+id/horizontal_line"
android:background="@color/irctc_menu_bg_color"
android:gravity="center"
android:text="Train Name"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/white"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/hr2"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/txtview_trainname"
android:background="@color/white"
android:orientation="vertical" />
<TextView
android:id="@+id/txtview_fromtostation"
android:layout_width="match_parent"
android:layout_height="36dp"
android:layout_below="@+id/hr2"
android:background="@color/irctc_menu_bg_color"
android:gravity="center"
android:text="Station Name"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/white"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/hr3"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/txtview_fromtostation"
android:background="@color/white"
android:orientation="vertical" />
<LinearLayout
android:id="@+id/layout_table_header"
android:layout_width="match_parent"
android:layout_height="46dp"
android:layout_below="@+id/hr3"
android:background="@color/irctc_menu_bg_color"
android:orientation="horizontal">
<TextView
android:id="@+id/textView6"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:gravity="center"
android:text="Date"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/white"
android:textStyle="bold" />
<TextView
android:id="@+id/txtview_class1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4"
android:gravity="center"
android:text="class1"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/white"
android:textStyle="bold" />
<TextView
android:id="@+id/txtview_class2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4"
android:gravity="center"
android:text="class2"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/white"
android:textStyle="bold" />
</LinearLayout>
<RelativeLayout
android:id="@+id/layout_bottom"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_above="@+id/btn_express_book"
android:layout_alignParentBottom="false"
android:background="@color/irctc_menu_bg_color">
<TextView
android:id="@+id/textView9"
android:layout_width="70dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="Quota:"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/white" />
<Button
android:id="@+id/btn_quota"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/imageView9"
android:layout_toRightOf="@+id/textView9"
android:background="@drawable/trans_button"
android:onClick="onClickQuota"
android:text="Selected Quota"
android:textColor="@color/white" />
<ImageView
android:id="@+id/imageView8"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:background="@drawable/trans_button"
android:clickable="true"
android:onClick="onClickTrainSchedule"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:scaleType="fitCenter"
android:src="@mipmap/train_schedule" />
<ImageView
android:id="@+id/imageView9"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_toLeftOf="@+id/imageView8"
android:background="@drawable/trans_button"
android:clickable="true"
android:onClick="onClickFareEnquery"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:scaleType="fitCenter"
android:src="@mipmap/fair_enquiry" />
</RelativeLayout>
<ListView
android:id="@+id/listview_seatcell"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/adView"
android:layout_below="@+id/layout_table_header" />
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/layout_bottom"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id" />
<Button
android:id="@+id/btn_express_book"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="4dp"
android:layout_marginTop="4dp"
android:background="@drawable/irctc_button"
android:onClick="onClickExpressBook"
android:paddingBottom="10dp"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:paddingTop="10dp"
android:text="Express Book!"
android:textColor="#ffffff" />
</RelativeLayout>
我在这里做错了吗?我需要对xml进行哪些更改以容纳带有操作栏的手机?
答案 0 :(得分:1)
尝试将android:layout_alignParentBottom =“false”设置为android:layout_alignParentBottom =“true”在布局中。所以这样的事情。
<RelativeLayout
android:id="@+id/layout_bottom"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_above="@+id/btn_express_book"
android:layout_alignParentBottom="true"
android:background="@color/irctc_menu_bg_color">
答案 1 :(得分:1)
我已经将ScrollView
添加到您的ViewGroup。检查一下:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/main_bg"
tools:context="com.myapp.SeatsActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
<RelativeLayout
android:id="@+id/actionbar_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/irctc_actionbar_height"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageView4"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerVertical="true"
android:layout_marginLeft="6dp"
android:onClick="onClickgoHome"
android:src="@mipmap/iconhome" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="4dp"
android:layout_toLeftOf="@+id/button11"
android:layout_toRightOf="@+id/imageView4"
android:gravity="center"
android:text="SEAT AVAILABILITY"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/white"
android:textStyle="bold" />
<ImageView
android:id="@+id/imageView5"
android:layout_width="@dimen/irctc_actionbar_height"
android:layout_height="@dimen/irctc_actionbar_height"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="@drawable/trans_button"
android:clickable="true"
android:onClick="onClickShare"
android:padding="4dp"
android:scaleType="fitCenter"
android:src="@mipmap/share" />
<Button
android:id="@+id/button11"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/imageView5"
android:onClick="onClickDate"
android:text="date:"
android:textColor="@color/white" />
</RelativeLayout>
<LinearLayout
android:id="@+id/horizontal_line"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/actionbar_layout"
android:background="@color/white"
android:orientation="vertical" />
<TextView
android:id="@+id/txtview_trainname"
android:layout_width="match_parent"
android:layout_height="36dp"
android:layout_below="@+id/horizontal_line"
android:background="@color/irctc_menu_bg_color"
android:gravity="center"
android:text="Train Name"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/white"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/hr2"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/txtview_trainname"
android:background="@color/white"
android:orientation="vertical" />
<TextView
android:id="@+id/txtview_fromtostation"
android:layout_width="match_parent"
android:layout_height="36dp"
android:layout_below="@+id/hr2"
android:background="@color/irctc_menu_bg_color"
android:gravity="center"
android:text="Station Name"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/white"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/hr3"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/txtview_fromtostation"
android:background="@color/white"
android:orientation="vertical" />
<LinearLayout
android:id="@+id/layout_table_header"
android:layout_width="match_parent"
android:layout_height="46dp"
android:layout_below="@+id/hr3"
android:background="@color/irctc_menu_bg_color"
android:orientation="horizontal">
<TextView
android:id="@+id/textView6"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:gravity="center"
android:text="Date"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/white"
android:textStyle="bold" />
<TextView
android:id="@+id/txtview_class1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4"
android:gravity="center"
android:text="class1"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/white"
android:textStyle="bold" />
<TextView
android:id="@+id/txtview_class2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4"
android:gravity="center"
android:text="class2"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/white"
android:textStyle="bold" />
</LinearLayout>
<RelativeLayout
android:id="@+id/layout_bottom"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_above="@+id/btn_express_book"
android:layout_alignParentBottom="false"
android:background="@color/irctc_menu_bg_color">
<TextView
android:id="@+id/textView9"
android:layout_width="70dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="Quota:"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/white" />
<Button
android:id="@+id/btn_quota"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/imageView9"
android:layout_toRightOf="@+id/textView9"
android:background="@drawable/trans_button"
android:onClick="onClickQuota"
android:text="Selected Quota"
android:textColor="@color/white" />
<ImageView
android:id="@+id/imageView8"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:background="@drawable/trans_button"
android:clickable="true"
android:onClick="onClickTrainSchedule"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:scaleType="fitCenter"
android:src="@mipmap/train_schedule" />
<ImageView
android:id="@+id/imageView9"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_toLeftOf="@+id/imageView8"
android:background="@drawable/trans_button"
android:clickable="true"
android:onClick="onClickFareEnquery"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:scaleType="fitCenter"
android:src="@mipmap/fair_enquiry" />
</RelativeLayout>
<ListView
android:id="@+id/listview_seatcell"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/adView"
android:layout_below="@+id/layout_table_header" />
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/layout_bottom"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id" />
<Button
android:id="@+id/btn_express_book"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="4dp"
android:layout_marginTop="4dp"
android:background="@drawable/irctc_button"
android:onClick="onClickExpressBook"
android:paddingBottom="10dp"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:paddingTop="10dp"
android:text="Express Book!"
android:textColor="#ffffff" />
</RelativeLayout>
</ScrollView>
希望有所帮助
答案 2 :(得分:1)
RelativeLayout
模仿LinearLayout
。您的所有观点都不重叠,并且它们都不需要与其他视图进行任何特殊对齐。使用layout_below
和layout_above
重新创建该内容会令人困惑。您的布局中的所有内容都可以使用LinearLayout
代替,并且会更加清晰,除了可能是两个操作栏(但即使是LinearLayout
也可以实现)。
LinearLayout
作为横向分隔符。如果您必须使用视图,只需使用View
即可。但是,如果你在#{1}}内进行此操作,正如我在#1中所建议的那样,那么你可能根本不需要视图,你可以使用
LinearLayout
并在android:showDividers="middle"
android:divider="@drawable/hr"
res/drawable/hr.xml
<shape android:shape="rectangle">
<size android:height="1dp" />
<solid android:color="@android:color/white" />
</shape>
作为wrap_content
的高度。 ListView
对其孩子一无所知。把它告诉它需要包含它们的高度并没有任何意义,ListView
只是试图猜测。您应该始终使用静态值ListView
,或者允许它使用match_parent
(如果使用layout_weight
)或其他视图边界(如果使用`RelativeLayout)填充某个任意空间。< / p>
结合以上所有内容,我认为您的布局应该看起来像这样(只显示相关部分):
LinearLayout