Ich habe ein Layout, das eine CardView enthält. Ich fügte Scrollview hinzu, fügte ich android:scrollable=vertical
in Textview hinzu, fügte ich hinzu mytxtview.setMovementMethod(new ScrollingMovementMethod());
Anzeige von Text in Cardview, passt nicht in Bildschirm
NICHTS funktioniert! Ich habe einen sehr großen Text in einer Textansicht und es passt nicht in den Bildschirm, ich kann den ganzen Text nicht sehen, bitte hilf mir. Hier ist mein Layout, bitte hilf mir.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:tag="cards main container">
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_viewfrag5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
card_view:cardBackgroundColor="#A9E2F3"
card_view:cardCornerRadius="10dp"
card_view:cardElevation="5dp"
card_view:cardUseCompatPadding="true"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_weight="2"
android:orientation="vertical"
android:weightSum="1">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbarfrag5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.96"
android:background="#A9E2F3"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme">
<ImageView
android:id="@+id/imageViewfrag5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_weight="1"
android:src="@drawable/testbild"
android:tag="image_tag" />
</android.support.v7.widget.Toolbar>
<TextView
android:id="@+id/textViewNamefrag5"
android:layout_width="340dp"
android:maxLines="25"
android:scrollbars="vertical"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:text="here is a very very very long text that does not fit into the screen"
android:layout_weight="0.96"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</ScrollView>
EDIT: Java-Code
public class Fragment5 extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
ViewGroup rootView = (ViewGroup) inflater.inflate(
R.layout.fragmentdescrip5, container, false);
TextView mytxtview = (TextView) rootView.findViewById(R.id.textViewNamefrag5);
mytxtview.setMovementMethod(new ScrollingMovementMethod());
return rootView;
}
}
Das hat das Problem leider nicht gelöst. – Blnpwr
Es ist nichts falsch mit der Layout-Datei oben (obwohl es ein bisschen chaotisch ist) Ich habe es gerade selbst getestet. Das Entfernen von 'maxLines =" 25 "' hat das Problem für mich behoben, also muss noch etwas anderes das Problem für dich verursachen. Veröffentlichen Sie die Layoutdatei für die Aktivität, in der Sie 'Fragment5' platzieren? – Bryan