2012-05-01 2 views
2

스크롤보기를 사용하는 레이아웃이 있습니다. 스크롤보기에서 텍스트의 첫 번째 부분은 에뮬레이터에서 잘리고 HTC 폰에서는 스크롤보기가 텍스트 끝을지나 스크롤되며 텍스트로 돌아가려면 많은 스크롤이 필요합니다.Android, 스크롤보기 및 쓸데없는 레이아웃

이클립스는 "이있는 ScrollView 레이아웃이나있는 LinearLayout 부모가 쓸모가"나는이 메시지가 내 불황의 주범이라고 생각하지만,

레이아웃 수정 될 행복 불평

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    style="@style/Container" 
    android:id="@+id/about"> 
     <ScrollView style="@style/Content"> 
       <TextView style="@style/Content" 
        android:id="@+id/about_content" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/about_text" /> 
     </ScrollView> 
</LinearLayout> 

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <style name="MainTheme"> 
     <item name="android:textColor">@color/txtColor</item> 
    </style> 
    <style name="ApplicationTheme" parent="android:Theme"> 
     <item name="android:layout_height">wrap_content</item> 
     <item name="android:layout_width">wrap_content</item> 
     <item name="android:colorBackground">@color/mnuColor</item> 
     <item name="android:textColor">@color/txtColor</item> 
    </style> 
    <style name="Container" parent="ApplicationTheme"> 
     <item name="android:textColor">@color/txtColor</item> 
     <item name="android:layout_height">fill_parent</item> 
     <item name="android:layout_width">fill_parent</item> 
     <item name="android:colorBackground">@color/mnuColor</item> 
    </style> 
    <style name="Webview" parent="Container"> 
     <item name="android:background">@drawable/web_background_image</item> 
     <item name="android:windowBackground">@drawable/background_image</item> 
     <item name="android:colorBackground">@color/mnuColor</item> 
    </style> 
    <style name="MyPlaceDialog" parent="@android:style/Theme.Dialog"> 
     <item name="android:layout_height">wrap_content</item> 
     <item name="android:layout_width">fill_parent</item> 
     <item name="android:orientation">vertical</item> 
     <item name="android:stretchColumns">*</item> 
    </style> 
    <style name="Content"> 
     <item name="android:layout_height">wrap_content</item> 
     <item name="android:layout_width">fill_parent</item> 
     <item name="android:layout_gravity">center</item> 
    </style> 

    <style name="button" parent="@android:style/Widget.Button"> 
     <item name="android:background">@drawable/button</item> 
     <item name="android:layout_marginTop">2dp</item> 
     <item name="android:layout_marginBottom">3dp</item> 
     <item name="android:layout_marginLeft">4dp</item> 
     <item name="android:layout_marginRight">4dp</item> 
     <item name="android:layout_width">wrap_content</item> 
     <item name="android:layout_height">wrap_content</item> 
    </style>  
</resources> 

안드로이드 문서가 완전히 도움 섬뜩 쓸모 스타일

는 레이아웃이 쓸모 일식 수 있습니다 왜되어 설명되지합니다 따라서이 문제를 해결하기 위해 내가해야 할 일에 대한 아이디어를 크게 얻으실 수 있습니다.

답변

7

선형 레이아웃은 단일보기를 수용합니다. 이 때문에 LinearLayout을 없애고 ScrollView를 레이아웃의 루트 요소로 만들 수 있습니다.

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" style="@style/Content"> 
    <TextView style="@style/Content" 
     android:id="@+id/about_content" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/about_text" /> 
</ScrollView> 

lint가 항상 100 % 정확하지는 않습니다. 뷰를 제거 할 수는 있지만 뷰어는 항상 원하는 것이거나 필요하지는 않습니다.

+0

실제로 작동하고 실제로 스크롤링 문제를 해결했습니다. 매우 감사합니다 – jamesc

관련 문제