Android的对话框宽度 [英] Android dialog width

查看:133
本文介绍了Android的对话框宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法控制对话框的宽度。我有一个像so`一个简单的布局

I can't seem to control the dialog width. I have a simple layout like so`

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="vertical"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:theme="@android:style/Theme.Dialog"> 
<ScrollView 
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout     android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">


    <TextView android:id="@+id/name_prompt_view"
        android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:text="@string/name_prompt"
     android:padding="10dip"/>
    <EditText android:id="@+id/name_inp" android:layout_width="fill_parent" 

 android:layout_height="wrap_content" 
   android:lines="1"
      android:maxLines="1"
      android:maxLength="48"
      android:inputType="text">
 </EditText>

  <TextView android:id="@+id/t1_prompt_view"
        android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:text="@string/t1_prompt"
     android:padding="10dip"/>
    <Spinner android:id="@+id/t1_inp" android:layout_width="fill_parent" 
 android:layout_height="wrap_content" 
   android:lines="1"
      android:maxLines="1"
      android:maxLength="48"
      android:inputType="text"
      android:singleLine="true"
      android:layout_weight="1"
      android:entries= "@array/t1_allowed_values">
 </Spinner>
     </LinearLayout>
</ScrollView>
</LinearLayout>

由于某种原因,该对话框只足够宽的文本输入区约11个字符宽。如何让我的对话框宽度填满整个屏幕?

for some reason the dialog is only wide enough for the text input field about 11 chars wide. How do I make the dialog width fill the screen?

推荐答案

我有同样的问题。

我用下面的code键使对话框FILL_PARENT它工作得很好。

i used following code to make dialog fill_parent and it worked fine.

public class SharePost extends Dialog
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.adaptor_contentsharepost);

        LayoutParams params = getWindow().getAttributes();
        params.height = LayoutParams.FILL_PARENT;
        getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);
    }
}

布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:id="@+id/dialogWidth"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    contents here

</LinearLayout>

这篇关于Android的对话框宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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