I know this question had been asked a lot but I really searched for an hour and still haven't found the answer. My TextView in my dialog fragment goes out of bounds, as in the texts inside.
The first textview was supposed to say "Adakah anda......." but it goes out of bounds just like that. I tried changing from wrap to match parent, then fill then weights but still won't change the problem, to autosize libraries (not what I wanted, I wanted to resize the textview, not textsize). Please help, tq.
Below is the XML Code
<LinearLayout
android:layout_width = "match_parent"
android:orientation="horizontal"
android:padding="3dp"
android:layout_marginBottom="30dp"
android:layout_height = "match_parent">
<TextView
android:id = "@+id/tvAdakah"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:layout_weight = "1"
android:text = "@string/adakah_anda_menstruasi_pada_hari_ini" />
<Switch
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:layout_gravity="right|center"
android:layout_weight="1"
android:gravity="right|center"/>
</LinearLayout>
Try using the following,
android:scrollHorizontally="true"
android:ellipsize="end"
android:maxLines="1"
for the textView, Maybe it can help
You can show it in one line and make moving text
use xml code like this
<TextView
android:id = "@+id/tvAdakah"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:layout_weight = "1"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:text = "@string/adakah_anda_menstruasi_pada_hari_ini" />
In java class you need to set selected this textView
TextView view = findViewById(R.id.tvAdakah);
view.setSelected(true);
hope it will helpful
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.