【问题标题】:Android Layout ElementsAndroid 布局元素
【发布时间】:2011-12-14 17:24:48
【问题描述】:

我正在尝试制作如下所示的 Android 布局。我有几个问题:

1 - FB 用于帖子的元素是什么?即,它看起来不像文本视图,但元素看起来像是用分隔线分隔每个帖子。此外,文本样式因人名和发布时间不同而不同。我想复制这个(减去图片),但我找不到合适的 UI 元素。

  1. 底部的元素叫什么?它就像一个静态菜单。 IE,它与菜单相同,但不是按“菜单”来访问它,而是始终在页面上。

最后,是否有关于如何制作漂亮、专业的布局(如市场上的应用程序)的优秀教程/示例?我在布局上找到的教程非常基础。我想了解存在哪些元素,所有属性的含义并查看示例等。到目前为止,我只能看到其他应用程序的功能。我想要一本手册或某种类型的参考手册。

【问题讨论】:

    标签: android layout


    【解决方案1】:

    对于“花哨”的文本视图,您可以制作一个承载 RelativeLayout> 的线性布局:

    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:layout_weight="0">
    <ImageView 
        android:id="@+id/userPhoto" 
        android:layout_height="64dip"
        android:layout_width="64dip"
    />
    <TextView
        android:id="@+id/userFullName"
        android:layout_height="25dp"
        android:layout_width="fill_parent"
        android:layout_marginLeft="70dp"
    />
    </RelativeLayout>
    

    一旦你有了一个相对布局,你就可以在其中添加不同的视图来创建一种自定义视图。

    至于好的例子,我会看this book。这很容易理解并且对这些事情很有帮助。

    【讨论】:

    • 感谢您的建议,这本书应该会在几天后到。你知道图片底部的静态菜单的名称吗?另外,FB 是使用文本框来保存他们的消息还是其他类型的对象?
    • @user836200 这似乎是一个简单的 LinearLayout,其中包含 ImageButton 元素。按钮的设计将在其他地方完成,图像本身放置在本地资源目录中。 (例如
    • 他们可能只是在使用 TextView
    • 谢谢!知道如何处理静态菜单吗?或者知道它叫什么?
    • 我按照这个例子弄清楚了:stackoverflow.com/questions/2777098/…
    【解决方案2】:

    我发现了一个非常有用的 tutorial 来解决 ListView Row 设计中的问题,有点像你的问题。它进一步解释了如何进行异步图像加载,但第一部分应该对您有所帮助。

    另外,我可能是错的(我对此还是有点陌生​​),但我认为除了用户名和元素的相对位置之外,上面的答案缺少用于实际消息的 TextView,因为它是相对布局。比如:

    <TextView
        android:id="@+id/userName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@id/userPhoto"
        android:layout_toRightOf="@id/userPhoto"
        android:textSize="17dp"
        android:textStyle="bold" />
    
    <!-- actual message -->
    <TextView
        android:id="@+id/message"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/userName"
        android:layout_marginTop="1dip"
        android:layout_toRightOf="@id/userPhoto"
        android:textSize="15dp" />
    

    组织相对布局的关键是:

    android:layout_alignTop="@id/userPhoto" android:layout_toRightOf="@id/userPhoto"

    android:layout_below="@id/userName" android:layout_toRightOf="@id/userPhoto"

    我可能错了,但如果有帮助,那就太好了!只是将我的一点添加到另一个答案中。 干杯

    【讨论】:

      猜你喜欢
      • 2023-03-10
      • 2021-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-16
      • 2016-09-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多