Android 如何设计比手机更大的布局';谁的屏幕?
我正在开发一个Android应用程序,我想在eclipse中设计一个大于屏幕高度的布局 我有一个片段的布局,这个片段将在Android 如何设计比手机更大的布局';谁的屏幕?,android,eclipse,layout,Android,Eclipse,Layout,我正在开发一个Android应用程序,我想在eclipse中设计一个大于屏幕高度的布局 我有一个片段的布局,这个片段将在FragmentActivity上的ScrollView中 这是我的片段的布局: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/user_pr
FragmentActivity
上的ScrollView
中
这是我的片段的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/user_pro_main_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/text_state"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/layout_state"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
我是否必须更改android:layout\u height=“match\u parent”以使其在eclipse的设计器上更大?
如果我想在eclipse designer上看到更大的布局,我该怎么办?您总是可以在布局高度中显式地设置精确的dp值,但当然,大多数时候我认为您不需要固定值,所以请按编程方式进行设置
LinearLayout yourLayout; // Get it by findViewById()
yourLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, your_calculated_height));
您可以设置
android:layout\u height=“wrap\u content”
,当您在物理屏幕之外添加子元素时,它将继续拉伸布局
至于在Eclipse上查看这个,我不确定。我个人会在设备上运行它来查看它 只需计算设备高度和宽度,并在运行时将int值添加到布局高度和宽度的计算高度和宽度
public void deviceDisplay(){
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
}
答案很简单:您不能在Eclipse编辑器上查看比屏幕更大的布局。 可能的解决办法:
1.注释部分俯视图(可见)以查看底部(不可见),然后在准备启动时取消注释。
2.将设备预览更改为更大的分辨率(Nexus 10),这将给您一些额外的空间。谢谢您的回答,但我需要在eclipse上设计视图时这样做。使用android:layout\u height=“wrap\u content”,您的布局高度将与内容高度匹配,而不是屏幕,当然应该是顶级布局