2017-03-14 9 views
1

私は、次のようなレイアウトがあります。SwipeRefreshLayoutは - 前の兄弟へのクリックを渡す

<?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> 

活動に:

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

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

クリックでURLへのすべてのタッチがSwipeRefreshLayoutによってインターセプトされるため、TextViewは機能しません。

TextViewのURLのCliksに対してSwipeRefreshLayoutを透明にすることはできますが、同時にスワイプを有効にすることはできますか?

+0

の間にいくつかの余裕をもってしてみてください:https://developer.android.com/ reference/android/view/ViewGroup.html#attr_android:descendantFocusability – AndroidRuntimeException

+0

助けになりません。レイアウト階層に注意してください。 – Alexey

答えて

0

はい、TextViewだけで、あなたのTextViewに対してIDをオンにしてからasing onClickイベントだけを使用します。このイベントは、あなたの活動や断片を呼び出すことができます。

は、[更新] XMLで

、このプロパティとこのプロパティを使用することができ、あなたのTextViewとあなたのswipelayout

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

問題を明確にするために投稿を編集しました。 – Alexey

+0

Aaaのokが、このケースでは、あなたのTextViewには、このようないくつかのプロパティを必要とする: アンドロイド:オートリンク=「ウェブ」 アンドロイドは:linksClickable =「true」を はリンクで問題なしそれ –

+0

を試してみてくださいません。リンクが表示され、SwipeRefreshLayoutをドロップするとリンクがクリック可能になります。しかし、SwipeRefreshLayoutではそれは表示されますが、クリック可能ではありません。 SwipeRefreshLayoutがすべての接触をインターセプトするためだと私は信じています。 – Alexey

関連する問題