2017-07-27 3 views
1

ここでは、テキストビューとスイッチを備えた単純な水平LinearLayoutを示します。水平線LinearLayoutのスイッチで計算された高さが発生する

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_centerInParent="true" 
    android:orientation="horizontal"> 

    <TextView 
     android:layout_width="200dp" 
     android:layout_height="wrap_content" 
     android:text="Change the visibility of the below Switch to experiment the height measurement." /> 

    <Switch 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:visibility="visible" /> 

</LinearLayout> 

このレイアウトのレンダリングには問題があります。下に示すように、テキストビューは切り取られており、線形レイアウトはコンテンツをラップできません。

switch bug

私はこの問題は消えスイッチを削除します。

誰でもこの問題を経験しましたか?これはバグですか?

ありがとうございます。

+0

あなたはそれが完璧に動作し、実際のデバイス上でそれを実行すると、心配もする必要はありません:) – shahid17june

+1

shahid17june @は、私の驚きに、それは起こりません。私にバグみたいだが、もっとよく見えるようにする必要がある –

+0

ここにあなたのすべてのXMLコードを投稿できますか? – shahid17june

答えて

0

アーカイブしますか?

<RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_centerInParent="true"> 

      <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_toLeftOf="@+id/switch" 
        android:text="Change the visibility of the below Switch to experiment the height measurement."/> 

      <Switch 
        android:id="@+id/switch" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentEnd="true" 
        android:layout_centerVertical="true" 
        android:visibility="visible"/> 

     </RelativeLayout> 
+0

相対レイアウトを使用して適切なレイアウトを得ることができます。しかし、私の質問は、線形レイアウトが異なる動作をする理由です。 – SafaOrhan

関連する問題