【问题标题】:Design a layout in android在android中设计布局
【发布时间】:2013-07-30 16:48:25
【问题描述】:

我想要的活动布局是 2个旋转器一个接一个 在微调器的右侧或左侧我想要一个图像视图 在微调器下方,我添加了各种 edittext 和 texviews。

我尝试了线性布局和相对布局都没有得到想要的结果。

我应该使用哪种布局?

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="72dp"
    android:layout_height="61dp"
    android:src="@drawable/ic_launcher" />



<Spinner
    android:id="@+id/spinner1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="9" 
      android:entries="@array/category"
    android:prompt="@string/country_prompt"/>

    <LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:orientation="vertical" >
</LinearLayout>
</LinearLayout>

【问题讨论】:

  • 你有一些你想要实现的架构/草图吗?在我看来,LinearLayout 是最好的选择,但如果我们能看到您想要实现的目标,那就太好了。
  • 另外,你能发布整个 XML 布局吗?您至少缺少 RelativeLayout 和根 ScrollLayout 的结束标记。结束标签前还有其他视图吗?
  • 我的主要问题只是希望 imageview 和 spinner 在同一水平线上.....即在 spinner 右侧的 imageview...

标签: android layout imageview spinner


【解决方案1】:

你应该做到以下几点:

1) take linear layout with horizontal orientation.

2) put image view and spinner in it...and give the weight for both according to ratio of 10.

3) Same thing for another spinner and imageview.

4) And finally you have added editext below spinner in vertical layout.

您可以使用它并获得您的解决方案:

<LinearLayout
    android:id="@+id/linear"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/linear1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:src="@drawable/ic_launcher" />

        <Spinner
            android:id="@+id/spinner1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_weight="1" />
    </LinearLayout>
</LinearLayout>

【讨论】:

  • 我正在按照你所说的进行垂直布局“这个 LinearLayout 视图没用(没有孩子,没有背景,没有 id,没有样式)”
  • 但是你有没有正确设置微调器和使用权重的图像?
  • 在这里发布您的屏幕截图,以便我可以为您提供适当的解决方案
  • 我想要的是它下面的另一个微调器,其余的编辑文本仅在水平东方
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-05-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-13
相关资源
最近更新 更多