滚动的TextView价值被切断 [英] Scrolling TextView value are cut off

查看:176
本文介绍了滚动的TextView价值被切断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的TextView:

I have a simple TextView:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context=".MainActivity"
    tools:showIn="@layout/activity_main">

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:singleLine="true"
        android:ellipsize="marquee"
        android:scrollHorizontally="true"/>

</RelativeLayout>

文本值与...,这是问题切断?

在这里输入的形象描述

Dinamically我有滚动运动的简单activty:

Dinamically I have a simple activty with scrolling movement:

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.method.ScrollingMovementMethod;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        TextView t = (TextView) findViewById(R.id.textView);
        t.setMovementMethod(new ScrollingMovementMethod());
        t.setSelected(true);
    }
}

感谢您提前

SOLUTION :不设置setMovementMethod但只的setSelected(真),如果是必要的。见伊薇特答复意见。

SOLUTION: not set setMovementMethod but only setSelected(true) if is necessary. See comments in Yvette answer.

推荐答案

我把这个了。

app:layout_behavior="@string/appbar_scrolling_view_behavior"

和从previous问题中新增功能<一个href=\"http://stackoverflow.com/questions/33547967/horizontalscrollview-cut-the-text-in-a-textview-and-autoscorlling\">HorizontalScrollView剪切的文本在一个TextView和autoscorlling

and added the features from your previous question HorizontalScrollView cut the text in a TextView and autoscorlling

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin">

<TextView
    android:id="@+id/textView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:singleLine="true"
    android:ellipsize="marquee"
    android:scrollHorizontally="true"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:foregroundGravity="left"
    android:marqueeRepeatLimit="marquee_forever"
    android:maxLines="1"
    android:text="Title Song and too much information to display in one line."
    android:textAppearance="?android:attr/textAppearanceMedium"/>

</RelativeLayout>

在这里输入的形象描述

这篇关于滚动的TextView价值被切断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆