看不到我的布局一个ListView下一个按钮 [英] Can't see a button under a ListView in my layout

查看:139
本文介绍了看不到我的布局一个ListView下一个按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我的XML活动的布局:

有关某种原因,我无法看到按钮t我的屏幕的底部。
这里的code:

 <?XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:背景=@绘制/ app_bg
    机器人:方向=垂直><的LinearLayout
    机器人:layout_width =match_parent
    机器人:layout_height =WRAP_CONTENT>    <的LinearLayout
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:背景=@绘制/ bg_transparent
        机器人:方向=垂直
        安卓了minHeight =44dip
        安卓了minWidth =44dip>        <的TextView
            机器人:ID =@ + ID / lblNotesCount
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_gravity =CENTER_HORIZONTAL
            机器人:TEXTSIZE =18sp
            机器人:文字样式=大胆
            机器人:文字颜色=@色/ lblNotesCountColor/>        <的TextView
            机器人:ID =@ + ID / lblTxtNotes
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_gravity =CENTER_HORIZONTAL
            机器人:TEXTSIZE =14sp
            机器人:文字样式=大胆
            机器人:文字颜色=@色/ lblNotesCountColor/>
    < / LinearLayout中>
    <的TextView
        机器人:ID =@ + ID / txtActivityListByCategory_Header
        机器人:layout_width =0dp
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_weight =1
        机器人:ellipsize =结束
        机器人:重力=center_vertical | CENTER_HORIZONTAL
        机器人:paddingLeft =2DP
        机器人:单线=真
        机器人:文字样式=大胆
        机器人:文字颜色=@色/ color_WHITE/>    <按钮
        机器人:ID =@ + ID / btnAddNote
        风格=机器人:ATTR / buttonStyleSmall
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:背景=@绘制/ btn_new_note_selector
        安卓了minHeight =44dip
        安卓了minWidth =44dip/>
< / LinearLayout中><的TextView
    机器人:ID =@ + ID /的emptyList
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:paddingLeft =2DP
    机器人:文字=@字符串/ txtEmptyList
    机器人:textAppearance =机器人:ATTR / textAppearanceMedium
    机器人:文字颜色=@色/的emptyList/>< ListView控件
    机器人:ID =@ + ID / lstNotesByCategory
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:drawSelectorOnTop =假>
< /&的ListView GT;
<按钮
    机器人:ID =@ + ID / btnaBack
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =WRAP_CONTENT
    机器人:文字=@字符串/ btnBack/>

我试图把在一个单独的LinearLayout底部的TextView和ListView,我试着给那个按钮layout_weight - 没有任何帮助,我还没有看到该按钮,则进入的LinearLayout直到活动的底部

什么是错在这里?为什么我没有看到那个按钮?

编辑:写下整个XML code


解决方案

请您ListView的的android:layout_height =0dp的android:layout_weight =1

这样的:

 < ListView控件
    机器人:ID =@ + ID / lstNotesByCategory
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =0dp
    机器人:layout_weight =1
    机器人:drawSelectorOnTop =假>
< /&的ListView GT;<按钮
    机器人:ID =@ + ID / btnaBack
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =WRAP_CONTENT
    机器人:文字=@字符串/ btnBack/>

这会使你的ListView垂直扩展,直到你的按钮的边框。

希望这有助于

Here's a layout of my Activity XML:

For some reason I can't see that button t the bottom of my screen. Here's the code:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/app_bg"
    android:orientation="vertical" >    

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/bg_transparent"
        android:orientation="vertical"
        android:minHeight="44dip"
        android:minWidth="44dip" >

        <TextView
            android:id="@+id/lblNotesCount"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:textSize="18sp"
            android:textStyle="bold"
            android:textColor="@color/lblNotesCountColor" />

        <TextView
            android:id="@+id/lblTxtNotes"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:textSize="14sp"
            android:textStyle="bold"
            android:textColor="@color/lblNotesCountColor" />
    </LinearLayout>


    <TextView
        android:id="@+id/txtActivityListByCategory_Header"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:ellipsize="end"
        android:gravity="center_vertical|center_horizontal"
        android:paddingLeft="2dp"
        android:singleLine="true"
        android:textStyle="bold"
        android:textColor="@color/color_WHITE" />

    <Button
        android:id="@+id/btnAddNote"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/btn_new_note_selector"
        android:minHeight="44dip"
        android:minWidth="44dip" />
</LinearLayout>

<TextView
    android:id="@+id/emptyList"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:paddingLeft="2dp"
    android:text="@string/txtEmptyList"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="@color/emptyList" />

<ListView
    android:id="@+id/lstNotesByCategory"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:drawSelectorOnTop="false" >
</ListView>


<Button
    android:id="@+id/btnaBack"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/btnBack" />

I tried to put the bottom TextView and ListView in a separate LinearLayout, I tried to give that button a layout_weight - nothing helped, I still don't see that button, the LinearLayout goes till the bottom of the activity.

What is wrong here? Why don't I see that button?

EDIT: Wrote down the entire XML code

解决方案

Make your ListView's android:layout_height="0dp" and android:layout_weight="1"

Like this:

<ListView
    android:id="@+id/lstNotesByCategory"
    android:layout_width="wrap_content"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:drawSelectorOnTop="false" >
</ListView>

<Button
    android:id="@+id/btnaBack"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/btnBack" />

This will make your ListView expand vertically till the borders of your Button.

Hope this helps

这篇关于看不到我的布局一个ListView下一个按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆