Android 如何管理所有设备中的边距
我正在做一个布局,它应该支持所有设备。我已经阅读了开发人员文档,我得出的结论是,我必须为不同的设备制作不同的布局和一些提示。所以我开始使用Mdpi,因为它是一条基线。现在我的问题是,我不想把我的观点放在中间,而是集中在每一边,我的意思是顶部,左侧 右下角,我想将微调器设置为文本字段,文本字段位于微调器的左侧。我还希望在更大的设备上,该微调器与文本字段的距离应与mdpi中的距离相同 假设我有一个主布局,其宽度和高度设置为填充父级,我希望其中有另一个或多个布局,从左到右具有相同的距离,并且此布局中的视图(如文本字段和微调器)具有一些特定的距离,当我们移动到更大的屏幕设备时,这些距离不应弄乱。我想你已经明白我的意思了,我不能分享我的照片,因为我没有足够的声誉。因此,我正在为我想要的布局共享此链接。 有什么帮助吗?请寄给我基本的xml代码,谢谢 编辑问题并在此处添加我的xml代码我迄今为止所做的尝试:Android 如何管理所有设备中的边距,android,android-layout,Android,Android Layout,我正在做一个布局,它应该支持所有设备。我已经阅读了开发人员文档,我得出的结论是,我必须为不同的设备制作不同的布局和一些提示。所以我开始使用Mdpi,因为它是一条基线。现在我的问题是,我不想把我的观点放在中间,而是集中在每一边,我的意思是顶部,左侧 右下角,我想将微调器设置为文本字段,文本字段位于微调器的左侧。我还希望在更大的设备上,该微调器与文本字段的距离应与mdpi中的距离相同 假设我有一个主布局,其宽度和高度设置为填充父级,我希望其中有另一个或多个布局,从左到右具有相同的距离,并且此布局中的
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:padding="50dp"
android:id="@+id/main_id"
android:background="@color/bright_foreground_inverse_material_light"
xmlns:android="http://schemas.android.com/apk/res/android">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="@dimen/activity_vertical_margin"
android:id="@+id/scrollView">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/l_team"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/select_a_team"
android:id="@+id/tv_team"
android:layout_alignParentTop="true" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/select_a_team"
android:id="@+id/tv_team_gone"
android:layout_alignParentTop="true" />
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/sp_team"
android:layout_below="@+id/tv_team"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/l_call_date"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/call_date_time"
android:id="@+id/tv_call_date"
android:layout_alignParentTop="true" />
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/sp_call_date"
android:layout_below="@+id/tv_call_date"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/l_first_name"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/first_name"
android:id="@+id/tv_first_name"
android:layout_alignParentTop="true" />
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/sp_first_name"
android:layout_below="@+id/tv_first_name"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/l_last_name"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/last_name"
android:id="@+id/tv_last_name"
android:layout_alignParentTop="true" />
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/sp_last_name"
android:layout_below="@+id/tv_last_name"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/l_Other_criteria"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/other_critera"
android:id="@+id/tv_Other_criteria"
android:layout_alignParentTop="true" />
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/sp_Other_criteria"
android:layout_below="@+id/tv_Other_criteria"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/l_order_by"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/order_by"
android:id="@+id/tv_order_by"
android:layout_alignParentTop="true" />
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/sp_order_by"
android:layout_below="@+id/tv_order_by"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/l_results_per_page"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/results_per_page"
android:id="@+id/tv_results_per_page"
android:layout_alignParentTop="true" />
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/sp_results_per_page"
android:layout_below="@+id/tv_results_per_page"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
</RelativeLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
你的意思是这样的吗
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/Main_Layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="20dp">
<LinearLayout
android:id="@+id/Inner_Layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="10.0"
android:background="#333"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="6.0"
android:background="#333"
android:orientation="vertical"></LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="4.0">
<EditText
android:layout_width="120dp"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/spinner"
android:layout_below="@+id/editText"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
我希望这会对你有所帮助
祝您好运有任何布局XML代码吗?没有,我没有做任何XML布局,我想问大家我应该做些什么才能得到这个结果,因为我想感谢@Im NeW....@Im NeW您能帮我提供一个代码吗。拜托?不,这不是我想要的看看我在链接中分享的图片。您的xml是从中间开始的,ad微调器不在文本视图的右侧。例如,您可以使用LinearLayout和RelativeLayout的布局权重。以及旋转器的位置。。你可以在相对区域内移动它。即使在Eclipse的designview中,Android StudioI和Android StudioI都添加了一段xml代码,但请检查它是否良好?是否要构建类似ListView的东西?为什么不使用并用适配器和带有和的预设xml文件填充它呢?看一看,或者如果我帮你回答了这个问题,请检查和/或投票。谢谢=)