按钮未显示在屏幕上 [英] Button not showing up on screen
本文介绍了按钮未显示在屏幕上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个应用,在其中显示带有图像和文本的listview.我在页面末尾添加Button.但是,这没有显示在屏幕上.我是android的新手.如何解决此问题?
I have created an app where i showing listview with an image and text . I add Button in the end of page . But this is not showing on screen .I am new in android .How can i solve this ?
这是我的UI XML代码:
Here is my UI XML Code :
<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"
android:padding="8dp"
tools:context=".MainActivity"
android:background="@drawable/maps">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/WAYLF"
android:gravity="center"
android:textSize="22sp" />
<ListView
android:id="@+id/list_view"
android:dividerHeight="4dp"
android:cacheColorHint="@android:color/transparent"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:layout_width="match_parent"
android:layout_height="35dp"
android:text="@string/NEXT"
android:background="@android:color/holo_green_light"
android:layout_marginTop="25dp" />
推荐答案
按如下所示将android:layout_height="0dip"
和android:layout_weight="1"
设置为ListView
...
Set android:layout_height="0dip"
and android:layout_weight="1"
to ListView
as below...
<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:background="@drawable/maps"
android:orientation="vertical"
android:padding="8dp"
tools:context=".MainActivity" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/WAYLF"
android:textSize="22sp" />
<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:cacheColorHint="@android:color/transparent"
android:dividerHeight="4dp" />
<Button
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_marginTop="25dp"
android:background="@android:color/holo_green_light"
android:text="@string/NEXT" />
</LinearLayout>
这篇关于按钮未显示在屏幕上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文