Android 在TextView中声明自动链接将隐藏文本。。。!

Android 在TextView中声明自动链接将隐藏文本。。。!,android,android-studio,textview,autolink,Android,Android Studio,Textview,Autolink,我正在尝试为TextView定义autolink=web。令人惊讶的是,当我声明这一点时,TextView中的文本隐藏起来,只有在第一次单击时才可见。这是如此令人惊讶,我在我的应用程序的许多部分都有相同的功能,而且运行良好。这是我唯一找不到问题所在的地方 请帮助我找到一个解决方案: 以下是我的TextView XML代码: <TextView android:id="@+id/details_webAddress_textView" andr

我正在尝试为TextView定义autolink=web。令人惊讶的是,当我声明这一点时,TextView中的文本隐藏起来,只有在第一次单击时才可见。这是如此令人惊讶,我在我的应用程序的许多部分都有相同的功能,而且运行良好。这是我唯一找不到问题所在的地方

请帮助我找到一个解决方案:

以下是我的TextView XML代码:

<TextView
            android:id="@+id/details_webAddress_textView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/details_location_textView"
            android:drawableLeft="@drawable/icon_website_earth"
            android:drawablePadding="5dp"
            android:gravity="center"
            android:padding="5dp"
            android:singleLine="true"
            android:autoLink="web"
            android:text="www.google.com"
            android:visibility="visible" />
以下是自动链接工作正常的文本视图:

<TextView
                android:id="@+id/websiteAddress_textView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:autoLink="web"
                android:padding="5dp"
                android:singleLine="true"
                android:text="www.stackoverflow.com" />
试用:

TextView textLink = (TextView) findViewById(R.id.details_webAddress_textView);
textLink.setVisibility(View.INVISIBLE);
Button buttonDetails = (Button) findViewById(R.id.button);

buttonDetails.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                textLink.setVisibility(View.VISIBLE); // text visible on firt click
                String url = "http://www.example.com";
                Intent i = new Intent(Intent.ACTION_VIEW);
                i.setData(Uri.parse(url));
                startActivity(i); // open link with default browser
            }
        });

除了android:autoLink属性之外,您还需要在xml中设置android:textColorLink属性

<TextView
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:autoLink="web"
     android:textColorLink="@color/yourDesiredLinkColor"/>

... 也许您应该发布应用程序其他部分中同样的代码片段?原因是android:singleLine=true