This is probably a very dumb question, but I had a few questio开发者_开发技巧ns about what the layout XML looks like for these list items
I know there are three textviews, but how did they left indent the last line? Also, how did they cause the second textview to wrap after a set amount of lines?
If someone could post sample XML, that would be awesome too.
use the following xml, last textview is to the right.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:maxLines="2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:maxLines="5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_gravity="right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
The last TextView is either layout aligned to the right (layout_gravity), or it matches the parent width and has its gravity (not the layout one, but its own) to right.
To ellipsize the second TextView, give it a valid height and then set the ellipsize attribute to end.
The recipe is ScrollView + TextView + LinearLayout + gravity. For the same look, check :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ScrollView
android:id="@+id/sv"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:textSize="24dip"
android:layout_height="wrap_content"
android:text="Morning"
/>
<TextView
android:layout_width="fill_parent"
android:textSize="14dip"
android:layout_height="wrap_content"
android:text="Layout container for a view hierarchy that can be scrolled by the user, allowing it to be larger than the physical display. A ScrollView is a FrameLayout, meaning you should place one child in it containing the entire contents to scroll; this child may itself be a layout manager with a complex hierarchy of objects. A child that is often used is a LinearLayout in a vertical orientation, presenting a vertical array of top-level items that the user can scroll through. "
/>
<TextView
android:layout_width="fill_parent"
android:textSize="12dip"
android:layout_height="wrap_content"
android:text="Morning"
android:gravity="right"
/>
<TextView
android:layout_width="fill_parent"
android:textSize="24dip"
android:layout_height="wrap_content"
android:text="Morning"
/>
<TextView
android:layout_width="fill_parent"
android:textSize="14dip"
android:layout_height="wrap_content"
android:text="Layout container for a view hierarchy that can be scrolled by the user, allowing it to be larger than the physical display. A ScrollView is a FrameLayout, meaning you should place one child in it containing the entire contents to scroll; this child may itself be a layout manager with a complex hierarchy of objects. A child that is often used is a LinearLayout in a vertical orientation, presenting a vertical array of top-level items that the user can scroll through. "
/>
<TextView
android:layout_width="fill_parent"
android:textSize="12dip"
android:layout_height="wrap_content"
android:text="Morning"
android:gravity="right"
/>
<TextView
android:layout_width="fill_parent"
android:textSize="24dip"
android:layout_height="wrap_content"
android:text="Morning"
/>
<TextView
android:layout_width="fill_parent"
android:textSize="14dip"
android:layout_height="wrap_content"
android:text="Layout container for a view hierarchy that can be scrolled by the user, allowing it to be larger than the physical display. A ScrollView is a FrameLayout, meaning you should place one child in it containing the entire contents to scroll; this child may itself be a layout manager with a complex hierarchy of objects. A child that is often used is a LinearLayout in a vertical orientation, presenting a vertical array of top-level items that the user can scroll through. "
/>
<TextView
android:layout_width="fill_parent"
android:textSize="12dip"
android:layout_height="wrap_content"
android:text="Morning"
android:gravity="right"
/>
</LinearLayout>
</ScrollView>
</LinearLayout>
(You can replace TextView
s by a ListView
)
EDIT : I guess everyone's giving you a bit of the solution here :).
精彩评论