Reputation: 821
When I use Android:margin to position textView half-outside it's parent, it acts weirdly: changes it's own size and text is moving inside textView box. How do I prevent it? On image: left textView has cropped text at the end, and I don't want that.
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="16dp"
android:clipChildren="false">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ellipsize="none"
android:singleLine="true"
android:textColor="#FFFFFF"
android:textSize="22.5dp"
android:layout_marginRight="200dp"
tools:text="0 TEXT VIEWVIEW"
tools:textColor="#000000" />
<...>
</FrameLayout>
Upvotes: 0
Views: 181
Reputation: 17841
You have two problems here:
FrameLayout
. This means that when you keep increasing the margin of child, the view is gonna move out of the parent. Why? Because that's how FrameLayout
is designed. Read documentation here: http://developer.android.com/reference/android/widget/FrameLayout.htmlFrameLayout is designed to block out an area on the screen to display a single item. Generally, FrameLayout should be used to hold a single child view, because it can be difficult to organize child views in a way that's scalable to different screen sizes without the children overlapping each other.
So instead you could use RelativeLayout
or LinearLayout
.
The second problem you have is android:singleLine="true"
. This means that as the text increases in length, it will still be shown in a single line and hence the text will be clipped. So set this to false
, or just remove this attribute.
android:singleLine="false"
Upvotes: 1
Reputation: 74
FrameLayout
always overlaps its Children. For effective placing widgets I suggest to use,
LinearLayout
with layout_weight
arrange widgets relative to another widget by using RelativeLayout
Upvotes: 2
Reputation: 460
i think you need to change the line:
android:singleLine="true"
to false.
Upvotes: 1