gpt4 book ai didi

java - 文本选取框不起作用

转载 作者:行者123 更新时间:2023-12-01 23:28:34 25 4
gpt4 key购买 nike

请看下面的代码

<TableRow
android:id="@+id/tableRow13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp" >

<TextView
android:id="@+id/textView22"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:textSize="12sp"
android:text="@string/r_new_event"
android:layout_marginLeft="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />

<TextView
android:id="@+id/textView23"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Meeting with people i have never seen before in my entire life lol"
android:ellipsize="marquee"
android:maxLength="10"
android:singleLine="true"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:textColor="#ffffff"
android:textSize="12sp"
android:layout_marginLeft="10dp"
android:textAppearance="?android:attr/textAppearanceSmall" />

</TableRow>

此尝试是在文本长度超过 10 个字母时对文本进行选取框显示。但不幸的是,这段代码不起作用。我在moth模拟器和Android手机上尝试过。这里出了什么问题?

更新

以下是我的新代码,它仍然无法工作

<TextView
android:id="@+id/textView23"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Meeting with people i have never seen before in my entire life lol"
android:ellipsize="marquee"
android:maxLength="10"
android:singleLine="true"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:textColor="#ffffff"
android:textSize="12sp"
android:layout_marginLeft="10dp"
android:focusable="true"
android:focusableInTouchMode="true"
android:freezesText="true"
android:textAppearance="?android:attr/textAppearanceSmall" />

最佳答案

试试这个代码..

XML

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/mywidget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:lines="1"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:textColor="#ff4500"
android:text="Simple application that shows how to use marquee, with a long text" />
</RelativeLayout>

主要 Activity

public class TextViewMarquee extends Activity {
private TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv = (TextView) this.findViewById(R.id.tv);
tv.setSelected(true); // Set focus to the textview
}
}

关于java - 文本选取框不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19658586/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com