Zac*_*Zac 11 android textview android-layout android-relativelayout
这是我得到的错误: W/TextView: TextView does not support text selection. Selection cancelled.
我很惊讶,因为Textviews我之前已经实现过的其他RelativeLayout文件在我拥有该属性时可以选择文本android:textIsSelectable="true"- 但是,这次不起作用.
此代码放在app_bar_main.xml使用includeXML中的关键字下.
这是app_bar_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true"
tools:context=".MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" /> //This is where the textview is added!
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
这是编辑过的content_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:background="#ffffff"
android:orientation="vertical"
tools:context="com.androidterminal.MainActivity"
tools:showIn="@layout/app_bar_main">
//I have some other LinearLayouts here
<RelativeLayout
android:id="@+id/ll5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/ll2"
android:orientation="horizontal">
<TextView
android:id="@+id/main1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorGrey"
android:textIsSelectable="true"
android:textColor="#000000" />
</RelativeLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
此TextView main1不可选,并在LogCat上引发上述警告.请帮忙.谢谢.(我已经尝试设置focusable和setFocusable属性)
您的代码工作正常,我不确定您的系统上有什么配置。
尝试以下修复
在Java中尝试一下。
textview.setTextIsSelectable(true);
textview.setFocusable(true);
textview.setFocusableInTouchMode(true);
Run Code Online (Sandbox Code Playgroud)将TextView宽度wrap_content从更改为match_parent。
| 归档时间: |
|
| 查看次数: |
1109 次 |
| 最近记录: |