开发者

Split button text into two sections

开发者 https://www.devze.com 2023-03-16 04:57 出处:网络
I am trying to port my WP7 app to android. Does anyone know how I can layout the text on a single button so that some text appears aligned left and other text appears aligned right?(See below).I need

I am trying to port my WP7 app to android.

Does anyone know how I can layout the text on a single button so that some text appears aligned left and other text appears aligned right? (See below). I need access to be able to dynamically change the percentage number on the right side using code but the text on the right is just stati开发者_StackOverflow社区c.

Anyone know the answer to this?

The image is here: http://i.imgur.com/zW7YV.png


Yes you could make it two buttons.

Remove all padding and margin from between them.

Set the same background drawable.

And just ensure when the left is clicked it invokes the right's onPress method (so it looks as if they depress together).

Or wrap the buttons/imageviews/textviews in a layout and perform the onClick on that.


I would use a RelativeLayout for this.

<RelativeLayout
  android:width="fill_parent"
  android:height="wrap_content"
  android:clickable="true"
  android:background="#18a2e7"
  android:padding="10dip">
  <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Something" />
  <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_align_parentRight="true"
    android:text="0%" />
</RelativeLayout>
0

精彩评论

暂无评论...
验证码 换一张
取 消