I want the row to be scale automatically. The effect of my code is really strange...
i can't post images, so image is here: http://i.stack.imgur.com/NQfkO.jpg
the code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#FFFFF0"
>
<TextView
android:id="@+id/number"
android:layout_width="wrap_content"
android:layout_height="60dip"
android:gravity="center_vertical"
android:textSize="25sp"
android:textColor="#CBCBCB"
/>
<TextView
android:id="@+id/label"
android:minHeight="60dip"
android:maxHeight="120dip"
android:layout_width="220dip"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:gravity="center_vertical"
android:textSize="25sp"
android:textColor="#0f93b8"
/>
<TextView
android:id="@+id/people"
android:layout_width="fill_parent"
android:la开发者_JS百科yout_height="60dip"
android:gravity="right"
android:textSize="12sp"
android:textColor="#CBCBCB"
/>
</LinearLayout>
There might be some confusion in what you are wanting to scale. To have the TextView scale automatically depending on the length of the content, you can set the height to non concrete values using wrap_content. This along with a minimum height will give you views that always display your content however they may not fit on one screen (you may have to put the overall view in a scrollview or a listview with the rows as elements).
If you want the Text itself to scale "automagically" ... well that's a little tougher as by default that behavior does not exist. You will have to measure the space left using the Canvas of the TextView and figure out the correct fontmetrics to use for the space available. I would extend TextView for this and override the various onMeasure() and draw() methods to determine the correct font needed. If your TextViews are of fixed size, it will simplify the task greatly.
精彩评论