1

Android 2.3.3

I have an activity, that is displayed using the below code.

<activity android:name="com.xx.xxx.CombinationActivity"
    android:label=""
    android:theme="@android:style/Theme.Dialog">            
</activity>

Here is the Layout :

<?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:layout_gravity="center"
    android:gravity="center"
    android:background="#000000"
    android:orientation="vertical" >


    <!-- Beginner / Intermediate and so on -->
    <TextView
        android:id="@+id/textview_choose_level_main_title_1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:text="@string/text_choose_level_main_title_1"
        android:textColor="#FFFFFF"
        android:layout_marginBottom="20dp"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/textview_choose_level_1_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:text="@string/text_choose_level_1_default_title"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="#FFFFFF" />

    <TextView
        android:id="@+id/textview_choose_level_1_range"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:text="@string/text_choose_level_1_default_range"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="#FFFFFF" />

    <SeekBar
        android:id="@+id/seekbar_choose_level_1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="20dp"
        android:max="100" />

    <TextView
        android:id="@+id/textview_choose_level_empty"
        android:layout_width="match_parent"
        android:layout_height="20dp"
        android:gravity="center_horizontal"
        android:text=""
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="#FFFFFF" />


    <!-- 2 / 3 / 4 / 5  -->
   <TextView
        android:id="@+id/textview_choose_level_main_title_2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:text="@string/text_choose_level_main_title_1"
        android:textColor="#FFFFFF"
        android:layout_marginBottom="20dp"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/textview_choose_level_2_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:text="@string/text_choose_level_1_default_title"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="#FFFFFF" />

    <TextView
        android:id="@+id/textview_choose_level_2_range"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:text="@string/text_choose_level_1_default_range"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="#FFFFFF" />

    <SeekBar
        android:id="@+id/seekbar_choose_level_2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="20dp"
        android:max="100" />

</LinearLayout>

When I run the app, I get the what is displayed in first image. I need it to be as second image.

Thanks in advance..

What it is now :

enter image description here

What I want :

enter image description here


Answer :::

To those who are looking for the solution of similar kind, I have found the answer from @Marko comment. Thanks Marko..

Here is the link : click here

Here is the solution :

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.your_layout);

    getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
}
4

3 回答 3

3

在设置了 Theme.Dialog 样式的活动中,执行以下操作:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.your_layout);

    getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
}
于 2013-07-05T12:53:18.747 回答
0

我只是猜你想要什么。。

我认为您希望活动填满您的屏幕

试试这个代码

android:layout_width="fill_parent"

代替

 android:layout_width="match_parent"
于 2013-07-05T12:44:12.913 回答
0

Use

android:layout_width="match_parent"
android:minWidth="1000dp"

Your dialog will now fill the screen width.

于 2013-07-05T12:47:02.597 回答