简体   繁体   English

如何使ListViewItem看起来像Twitter应用程序?

[英]How can I make my ListViewItem look like the Twitter app?

I want my row items to look like this: 我希望我的行项目看起来像这样: 替代文字

I want to have an image on the left, top and bottom text and a date. 我想在左侧,顶部和底部的文字以及日期上添加图片。 I have started to lay it out, but am not sure how to proceed with the rest of the XML: 我已经开始进行布局,但是不确定如何继续其余的XML:

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/RelativeLayout01" xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content">

     <ImageView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:id="@+id/avatarImageView">
     </ImageView>
    <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:id="@+id/usernameTextView" 
        android:text="username" 
        android:layout_toRightOf="@+id/avatarImageView"
        android:layout_alignParentTop="true">
    </TextView>

    <TextView 
        android:id="@+id/bodyTextView" 
        android:layout_below="@+id/usernameTextView" 
        android:layout_toRightOf="@+id/avatarImageView"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="body">
    </TextView>
    <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_toRightOf="@+id/usernameTextView" 
        android:id="@+id/dateTextView" 
        android:text="date">
    </TextView>
</RelativeLayout>

You'll want to check out RelativeLayout, its much easier for layouts like this, it'd be something like. 您将要查看RelativeLayout,它对于像这样的布局要容易得多,就像这样。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:padding="6dip">

<ImageView id="@+id/badge"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    .../>

<TextView id="@+id/title"
    android:layout_toRightOf="@id/badge"
    android:layout_alignParentTop="true"
    ....
    />

<TextView id="@+id/body"
    android:layout_below="@id/title"
    android:layout_toRightOf="@id/badge"
     ....
    />
</RelativeLayout>

Otherwise you need to nest mixed LinearLayouts, eg an outer left to right LinearLayout, then a nested vertical Lineaar Layout for title & body, etc. 否则,您需要嵌套混合的LinearLayouts,例如从左到右的外部LinearLayout,然后是用于标题和正文的嵌套的垂直Lineaar Layout,等等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使ListView行看起来像Twitter应用程序的[截屏]? - How can I make my ListView row look like the Twitter app [Screenshot]? 如何让我的应用看起来像一个标准的Android应用程序? - How do I make my app look like a standard Android app? 我可以让JFrame看起来像JWindow吗? - Can I make a JFrame look like JWindow? 我如何使我的答案看起来像[z1,z2…] - How do i make my answer look like [z1, z2 …] 如何使我的Android SwipeableCardViews更像IOS 7邮件应用程序(滑动以显示按钮) - How can I make my Android SwipeableCardViews more like the IOS 7 mail app (swipe to show buttons) 如何使用 org.json 在 Java 中创建一个 JSON 看起来像这个例子? - How can I make an JSON in Java with org.json which does look like this example? 如何使带图标的jlabel看起来像桌面图标? - How to make my jlabel with icon look like desktop icon? 如何在不更改其行为的情况下使ToggleButton看起来像RadioButton? - How can I make a ToggleButton look like a RadioButton without changing its behavior? 如何更改JavaFx的按钮使其看起来完全像这样? - How can I change my JavaFx's buttons to look exactly like this? 如何设置我的menuPopup样式,使其看起来像是关闭电源的菜单弹出窗口? - How can I stylize my menuPopup, to look like the menu popup for powering down?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM