【问题标题】:How to set a dialog themed activity width to screen width? [duplicate]如何将对话框主题的活动宽度设置为屏幕宽度? [复制]
【发布时间】:2011-02-27 01:22:36
【问题描述】:

我遵循here 描述的方法来创建一个 EditText 输入活动。但是视图并没有填满屏幕的宽度。如何判断是否适合屏幕宽度?

alt text http://img405.imageshack.us/img405/5057/activitythemed.png

<activity android:name="TextEntryActivity" 
          android:label="My Activity" 
          android:theme="@android:style/Theme.Dialog"/>

-

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:orientation="vertical"
    android:gravity="right"
    android:layout_height="wrap_content">
    <EditText
        android:text="@+id/txtValue"
        android:id="@+id/txtValue"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"></EditText>
    <Button
        android:text="Done"
        android:id="@+id/btnDone"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"></Button>
</LinearLayout>

【问题讨论】:

  • 我怀疑它是否是重复的。这个问题是关于以对话框为主题的活动,它与对话框不同。

标签: android


【解决方案1】:

另一种选择是使用 AlertDialog 代替 Dialog。

【讨论】:

    【解决方案2】:

    简短的回答是你不能。对话框仅用于包装其内容。如果您希望内容填满屏幕,您应该使用活动

    【讨论】:

      【解决方案3】:

      在您的 LinearLayout 中设置 android:minWidth 和/或 android:minHeight

      【讨论】:

      • 到"fill_parent",同android:layout_width
      • 那行不通。错误:错误:不允许使用字符串类型(在“minWidth”处,值为“fill_parent”)。
      • 抱歉,我的回答不是简短。您可以使用这些属性来强制设置最小尺寸,即 android:minWidth="200dip" android:minHeight="400dip"。您必须绝对指定大小,因此“wrap_content”和“fill_parent”将不起作用。
      猜你喜欢
      • 2015-07-16
      • 2018-05-08
      • 1970-01-01
      • 2014-02-09
      • 2012-09-13
      • 1970-01-01
      • 2012-08-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多