Lieuwe
Lieuwe

Reputation: 1840

Layout troubles

I am having a spot of bother with a fairly simple layout. Here it is:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

  <TextView
        android:id="@+id/id1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:ellipsize="end"
        android:maxLines="1"/>

  <TextView
        android:id="@+id/id2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceSmall"/>
</LinearLayout>

3 Questions:

Upvotes: 0

Views: 62

Answers (1)

Yash
Yash

Reputation: 71

Best way is to use Relative layout , but still if you want to do the same thing in Linear layout than do some changes in your xml file -First is set Linear layout hight as match parent :

<LinearLayout android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="horizonatal">

-Second for making the views visible at centre vertical do

android:layout_gravity="center_vertical"

same property android:layout_gravity = "center_horizontal" , you have to add in second text view also.

It will make your both text view appear at centre vertical but one next to other. To make the second view appear on right I think you can add android:layout_marginLeft="xx dp" put some value in place of xx.

For your third question about truncating your text, you should give some size to your TextView not wrap content..Like android:layout_width ="25dp" and then use android:ellipsize="end".

I guess you will get that..Actually I am in hurry,time to leave the office.

Upvotes: 2

Related Questions