繁体   English   中英

RelativeLayout中的SwipeRefreshLayout - 将点击次数传递给上一个兄弟

[英]SwipeRefreshLayout in RelativeLayout - pass clicks to previous sibling

我有以下布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/message"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.v4.widget.SwipeRefreshLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </android.support.v4.widget.SwipeRefreshLayout>

</RelativeLayout>

在活动中:

TextView tv = (TextView) findViewById(R.id.message);
tv.setText(Html.fromHtml(getResources().getString(R.string.message));

在strings.xml中

<string name="message"><![CDATA[Visit <a href="http://example.com">this site</a>]]></string>

单击TextView中的URL不起作用,因为SwipeRefreshLayout拦截了所有触摸。

我怎样才能使SwipeRefreshLayout对于TextView的url中的cliks透明,但同时让滑动工作?

是的,仅将TextView作为ID,然后将onClick事件仅作为TextView。 您可以在活动或片段中调用此事件。

[更新]

在XML中,尝试使用此属性以及Textview和swipelayout之间的一些边距

    android:autoLink="web"
    android:linksClickable="true"
    android:marginBottom="10dp"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM