studio programacion herramientas fundamentos con avanzado aplicaciones android android-layout android-widget

android - programacion - Marquee no funciona mientras se usa en mĂșltiples textviews



manual de android en pdf (3)

Estoy bastante seguro de que no puedes hacer lo que quieres. Solo las vistas enfocadas pueden "marquesina", y como no puede tener dos vistas enfocadas, es imposible hacer lo que desea de inmediato. Sin embargo, puede ver el método startMarquee() en TextView y extender una vista de texto personalizada que siempre marque.

Estoy usando marquesina en dos TextViews diferentes de mi widget. Pero está trabajando solo para el primer o el segundo TextView cuando estoy intentando con diferentes combinaciones de "android: focusable =" true "", android: focusableInTouchMode = "true" y android: duplicateParentState = "true". Quiero que ambos TextViews se muevan. Estoy dando debajo del código que estoy usando.

<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>

¿Alguien puede saber la solución?


Alternativamente, también puede simplemente seleccionar textViews. Eso los enfoca y activa la marquesina. Trabajé para mí con vistas de texto dentro de una lista.


En 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); } }

En 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''s 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)." />