I am trying for some hours now to get rid of the following problem and I search and applied the methods I found here and on other sites, but the result is still bad. Please have a look at the following screenshot: Screenshot of cut off text
This is my xml part:
<HorizontalScrollView
android:layout_width="367dp"
android:layout_height="355dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginTop="8dp"
android:fillViewport="true"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btn_search">
<ListView
android:id="@+id/listView_results"
style="@android:style/Widget.DeviceDefault.Light.ListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:background="@android:color/black"
android:clickable="true"
android:divider="@android:color/holo_orange_light"
android:dividerHeight="1dp"
android:scrollbars="horizontal|vertical"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btn_search" />
</HorizontalScrollView>
And this is what I have written in my Java file:
`
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, titleList) {
@Override
public View getView(int position, View convertView, ViewGroup parent){
// Get the Item from ListView
View view = super.getView(position, convertView, parent);
TextView tv = (TextView) view.findViewById(android.R.id.text1);
// Set the text size in ListView for each item
tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP,40);
tv.setSingleLine(true);
tv.setMaxLines(1);
tv.setHorizontallyScrolling(true);
tv.setHorizontalScrollBarEnabled(true);
//tv.setEllipsize(MARQUEE);
//tv.setMarqueeRepeatLimit(1000);
// Return the view
return view;
}
};`
As you can see I already tried the marquee option, but it did not show any effects. Can anyone if he/she knows where to read about a possible solution, because the sources I found could not help me at all. If you have any suggestions, I would be happy to read them. I want to thank anyone in advance for their help. This is a university project and my first Android Application - some complications here and there ^^.
I was wondering if a TextView or a ListView or a HorizontalScollView has a limit in the width and if so where it can be expanded if that is an option.
Cheers Durim
Try
android:layout_width="wrap_content"
at listview.
I found an answer now.
The HorizontalScrollView was creating a scrollable container that was exactly as width as the first entry of my ListView.
The Solutions I found:
1) You bring your longest line to the first place in your list (depending on the font family that is used it still could make problems).
2) I set the font family to "MONOSPACE" for all TextView inside my ListView and added spaces " " to the first line to make its number of characters equal to the number of characters of the longest line.
I hope this helps anyone some day. If you have any questions concerning this topic, let me know. Cheers
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.