【问题标题】:Button not appearing in my Linear Layout按钮未出现在我的线性布局中
【发布时间】:2011-05-16 17:50:21
【问题描述】:

我在垂直方向的 LinearLayout 中有一个按钮。不知道为什么按钮不显示?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical">
<com.commonsware.cwac.tlv.TouchListView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tlv="http://schemas.android.com/apk/res/org.stocktwits.activity"

    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:drawSelectorOnTop="false"
    tlv:normal_height="64dip"
    tlv:grabber="@+id/icon"
    tlv:remove_mode="slideRight"
android:layout_height="wrap_content"/>
<Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>

</LinearLayout>

【问题讨论】:

  • 如果你(暂时)取出TouchListView会出现吗?
  • 这个 android:id="@android:id/list" 正确吗?我认为正确的一个是 android:id="@+id/list"
  • 如果我拿出 TouchListView 就会出现。或者,TouchListView 也会出现,布局中没有按钮。

标签: java android listview button android-linearlayout


【解决方案1】:

android:height="wrap_content" 对于像ListView 这样的垂直可滚动小部件没有任何意义。将android:layout_weightLinearLayoutRelativeLayout 一起使用,以实现您想要实现的任何外观。

【讨论】:

【解决方案2】:

尝试将此添加到您的 LinearLayout:

android:layout_width="fill_parent"
android:layout_height="fill_parent"

我猜布局只是没有显示?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-20
    • 2015-08-11
    • 1970-01-01
    • 2011-01-31
    • 2021-05-03
    相关资源
    最近更新 更多