Marquee does not work during use in multiple text comments

I use marquee in two different TextViews of my widget. But it only works for the first or second TextView, when I try to use different combinations of "android: focusable =" true ", android: focusableInTouchMode = true" and android: duplicateParentState = "true". I want both TextViews to move. I give below code that I use.

<TextView android:id="@+id/place" android:layout_width="94dip" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:scrollHorizontally="true" android:lines="1" android:textColor="@color/white" android:focusable="true" android:focusableInTouchMode="true" > <requestFocus android:duplicateParentState="true" /> </TextView> <TextView android:id="@+id/weather_report" android:layout_width="110dip" android:layout_height="wrap_content" android:layout_below="@+id/place" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:scrollHorizontally="true" android:lines="1" android:textColor="@color/grey" android:focusable="true" android:focusableInTouchMode="true" > <requestFocus android:duplicateParentState="true" /> </TextView> 

Can anyone know a solution?

+3
source share
3 answers

I am sure that you cannot do what you want. Only focused looks can โ€œstand out,โ€ and since you cannot have two focused views, then it is impossible to do what you want out of the box. However, you can look at the startMarquee() method in a TextView and extend a custom TextView that always contains tents.

+2
source

Alternatively, you can also just select textViews. This puts them in focus and activates the tent. Worked for me with textual representations in the View list.

0
source

In MainActivity.java,

 package com.hardian.samplemarque; import android.os.Bundle; import android.app.Activity; import android.widget.TextView; public class MainActivity extends Activity { TextView tvText1,tvText2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); tvText1 = (TextView)findViewById(R.id.tvText1); tvText2 = (TextView)findViewById(R.id.tvText2); tvText1.setSelected(true); tvText2.setSelected(true); } } 

In activity_main.xml

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity" > <TextView android:id="@+id/tvText1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:scrollHorizontally="true" android:ellipsize="marquee" android:marqueeRepeatLimit ="marquee_forever" android:focusable="true" android:focusableInTouchMode="true" android:text="1 Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum" /> <TextView android:id="@+id/tvText2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:scrollHorizontally="true" android:ellipsize="marquee" android:marqueeRepeatLimit ="marquee_forever" android:focusable="true" android:focusableInTouchMode="true" android:text="2 It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like)." /> 

0
source

Source: https://habr.com/ru/post/1399928/


All Articles