injecteer
injecteer

Reputation: 20699

Text aligned left and right in a Button

I have a button which shall look like

[1         44.33]

so that the text is aligned to left and right at the same time.

Is it possible to achieve it with a single element, w/o introducing nested TextViews?

Upvotes: 0

Views: 173

Answers (2)

Jitendra Kumar. Balla
Jitendra Kumar. Balla

Reputation: 1213

Yes, you can check the ellipsize element in Button Tag.

Upvotes: 1

KDeogharkar
KDeogharkar

Reputation: 10959

You can set ellipsize to middle and set singleLine to true for Button.

<Button
            android:id="@+id/desc"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="so that the text is aligned to left and right at the same time.Is it possible to achieve it with a single element, w/o introducing nested TextViews?"
            android:textColor="#888686"
            android:ellipsize="middle"
            android:singleLine="true"
            android:textSize="15dp" />

Upvotes: 1

Related Questions