android - ViewFlipper 宽度正在包裹其内容并且 fill_parent 不起作用

标签 android xml layout viewflipper fill-parent

这是我的布局 XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
  <TableLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:stretchColumns="true">
    <TableRow
      android:background="#FF0000">
      <ViewFlipper
        android:id="@+id/viewer_something"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <LinearLayout
          android:id="@+id/view1"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:background="#CCCCCC">
          <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="button one" />
        </LinearLayout>
        <LinearLayout
          android:id="@+id/view2"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:background="#FFFFFF">
          <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="button two" />
        </LinearLayout>
      </ViewFlipper>
        </TableRow>
        <TableRow
          android:background="#FF0000">
          <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="button three" />
        </TableRow>
      </TableLayout>
    </LinearLayout>

简而言之,我在 TableRow 中有一个 ViewFlipper。即使所有元素都指定了 fill_parent,ViewFlipper 也会缩小到其内容的大小。在下面的屏幕截图中,ViewFlipper 具有灰色背景,TableRows 具有红色背景。

http://imgur.com/FPnsE

最佳答案

在 ViewFlipper 上设置 android:layout_weight="1" 就可以了。

关于android - ViewFlipper 宽度正在包裹其内容并且 fill_parent 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6244672/

相关文章:

PHP - SimpleXML 解析错误

ios - 实现 UIScrollView 时遇到问题

android - ListFragment addFooterView

android - 如何替换实现以在 Android Build.gradle 中编译。 (安卓工作室 2.3.3)

xml - 如何使用 XSLT 1.0 获取小写的 xml 节点

HTML CSS 主体自动调整大小

.net - 样式指南/布局 web.config 和 app.config 以获得持续支持的最佳方式

java - 我应该在哪里进行改造操作?

java - 在下面添加版本 ---BEGIN PGP MESSAGE---

java - XML 解析错误