简体   繁体   中英

how to cut a part TextView when a button become visible

In the project I'm working on one problem. Can I do this? The name in the center of the top panel attached to the centerInParent. Left of the text i have image. The name can be displayed on the entire width of the zone (when the button is invisible on the right.) If the button is visible, just to the right is cut the name, and the left side remains as it was.

[image][blaaaaaaaaaaaaaaaaaaaaaaaaaa] - when button invisible

[image][blaaaaaaaaaaaaaaaaaaaaaa...][button] - when button visible

//add below attributes in your textivew

android:ellipsize="end"
android:maxLength="50"
android:lines="1"
android:maxEms="9" //you can choose max length or max ems
android:singleLine="true"

Use relative layout.

image alignparent topleft. 
button aligntparent right. 
text right of image && left of button.

Use button Gone and button visible and not invisible.

您可以通过将按钮设置为Visibility.Hidden当您希望使其不可见时),以及在TextView上设置android:ellipsize="end".setEllipsize来实现。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM