机器人的RelativeLayout如何获得更小的尺寸窗口 [英] android RelativeLayout how to get smaller size window
本文介绍了机器人的RelativeLayout如何获得更小的尺寸窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不能让Theme.Dialog活动变得越来越小。结果
问题是,我只想一半HIGHT。结果
看看下面的图片了。
I cannot get the Theme.Dialog activity to get smaller.
The problem is that i want half the hight only.
Look at the picture down below.
下面是明显的:
<activity android:name=".PopUpSettings"
android:label="@string/app_name"
android:theme="@android:style/Theme.Dialog"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation">
下面是XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="15dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingBottom="15dp"
>
<com.hellberg.ptppservice.imageedit.ColorPicker
android:id="@+id/color_picker_popup_settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
/>
<TextView android:id="@+id/exampeltext_popup_settings"
android:text = "This is the best app in the world"
android:textSize="20sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/color_picker_popup_settings"
/>
<Button android:id="@+id/fontleft_button_popup_settings"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
/>
<Button android:id="@+id/fontright_button_popup_settings"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
/>
<TextView android:id="@+id/textlogo_popup_settings"
android:text = "©2011"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
下面的画面是:
推荐答案
这会做你想要什么。要知道,你会得到充分窗口高度所以用2分不会使其完全尺寸的一半。我想你的布局除以3,它看起来不错。
This will do what you want. Be aware that you'll get the full window height so dividing with 2 wont make it exactly half the size. I tried your layout dividing with 3 and it looks good.
public class DialogExampleActivity extends Activity {
private int mWindowHeight;
private static final int DIALOG_OPEN = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Display display = getWindowManager().getDefaultDisplay();
mWindowHeight = display.getHeight();
showDialog(DIALOG_OPEN);
}
@Override
protected Dialog onCreateDialog(int id) {
Dialog myDialog = new Dialog(DialogExampleActivity.this);
switch (id) {
case DIALOG_OPEN:
myDialog.setContentView(R.layout.my_dialog);
myDialog.setCancelable(true);
RelativeLayout rr = (RelativeLayout) myDialog.findViewById(R.id.relative_layout);
LayoutParams params = rr.getLayoutParams();
params.height = mWindowHeight / 3;
rr.setLayoutParams(params);
return myDialog;
}
return null;
}
}
这篇关于机器人的RelativeLayout如何获得更小的尺寸窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文