【发布时间】:2015-06-22 09:19:01
【问题描述】:
我对 Android UI 设计相当陌生。我正在尝试模仿以下 Living Social 屏幕截图的 UI 设计:
在这里构建 UI 元素的最佳方式是什么?这如何在 XML 中实现?我正在尝试使用 Android Eclipse UI 编辑器来拖放 UI 元素,但似乎我需要对 UI 进行动态编程。解决此类问题的推荐方法是什么?
到目前为止,我有以下内容:
<LinearLayout
android:id="@+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin">
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<ImageView
android:id="@+id/imageViewBackground"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="fill"
android:scaleType="fitXY"
android:src="@android:drawable/dialog_holo_dark_frame" />
<View
android:id="@+id/view1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<View
android:id="@+id/view2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<View
android:id="@+id/view3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:backgroundTint="@color/abc_search_url_text_normal"
android:gravity="bottom|end"
android:orientation="vertical" >
<Button
android:id="@+id/buttonBUY"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="BUY!" />
</LinearLayout>
</LinearLayout>
问题:
- 我正在使用父线性布局。在这里面,我有一个顶部的 ScrollView 和底部的 LinearLayout。底部的 LinearLayout 有一个 BUY NOW 按钮的子按钮。这是正确的父布局方案吗?
- ScrollView 内部是一个 ImageView,它与 ScrollView 的顶部对齐。然后,滚动视图内部是 X 个白框。如何将内部白框视图稍微放在 ImageView 的顶部?我需要以编程方式执行此操作吗?
- 推荐的创建内部白盒视图的方法是什么?我是否需要为每个文件创建一个单独的 .xml 视图文件?或者您会建议为每个白框使用一个片段吗?或者,我是否需要为每个白框实现自定义视图类?
谢谢
【问题讨论】:
-
您要做的第一件事是尝试使用 Android Studio,它为布局开发提供了非常好的选择,而不是 eclipse 提供的。
-
谢谢哈雷什。我将尝试 Android Studio。对于滚动视图中的白框,我应该如何处理?我应该创建一个片段、自定义视图,还是简单地为它们每个创建单独的 .xml 文件并使用 LayoutInflator 类?
-
另外,您知道与此示例类似的任何好的教程或示例应用程序吗?
-
使用支持实时布局编辑器的 Android Studio!
-
我认为你的白框可能看起来像卡片布局,所以必须在这里查看:developer.android.com/training/material/…
标签: android android-layout android-fragments android-view