0

私はAndroid開発に慣れていない相対性理論ですが、私はすぐに追いつくと思います。私はソフトボールチームのために作ったアプリを作り直しています。以前はGoogleのAppInventorを使用していましたが、多くの欠点に遭遇したため、現在Eclipseを使用して再作業を試みています。

とにかく、要点まで。LinearLayoutに余分なパディングが追加されているようですが、どこから来ているのかわかりません。

TabHostを使用して、上部にタブを作成しています(GoogleのTabsの例の修正バージョン)。

レイアウトXML:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/main_linlay_parent"
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  >

    <TabHost 
        android:id="@android:id/tabhost"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >

            <RelativeLayout
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/background"
                >        

                <!-- Allow the "Tabs" to scroll horizontally -->
                <HorizontalScrollView 
                    android:layout_width="match_parent" 
                    android:layout_height="match_parent" 
                    android:fillViewport="true" 
                    android:scrollbars="none" 
                    >

                    <!-- The "Tabs" widget -->
                    <TabWidget
                        android:id="@android:id/tabs"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" 
                        android:background="#000000"
                        />

                </HorizontalScrollView>

                <!-- Provide the "Content" the ability to vertically scroll -->
                <ScrollView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_marginTop="65dp"
                    >
                    <FrameLayout
                        android:id="@android:id/tabcontent"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        >
                        <LinearLayout
                            android:id="@+id/tabdata"
                            android:orientation="vertical"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                             >
                         </LinearLayout>
                    </FrameLayout>
                </ScrollView>
            </RelativeLayout>
    </TabHost>
</LinearLayout>

問題はandroid:layout_marginTop="65dp"ScrollViewのにあると思いますが、削除するとタブが消えます(タブコンテンツがその上にオーバーレイされていると想定しています)。

最後に、私が経験していることの例を示すスクリーンショットを示します(XML文字列を無視しますが、それでもその部分をマッサージする必要があります。データを使用して例を示したかっただけです)。 http://kahunaball.com/android/screenshot_0.jpg

4

1 に答える 1

0

XML を最初からやり直して小さなステップを踏んだ後、XML を作り直して、レイアウトの余分なパディングを解決することができました。

どの変更が違いを生んだかは 100% わかりませんが、 を に変更し、RelativeLayoutLinearLayout移動し、LinearLayoutTableLayout外に移動したFrameLayoutことが、このトリックを行ったのではないかと疑っています。

これに出くわす可能性があり、問題を解決した新しい XML を確認したい場合は、次のとおりです。

<?xml version="1.0" encoding="utf-8"?>
<TabHost 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
    <LinearLayout 
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/background">
        <HorizontalScrollView 
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fillViewport="true"
            android:scrollbars="none">
            <TabWidget 
                android:id="@android:id/tabs"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="#000000" />
        </HorizontalScrollView>
        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent" >
            <HorizontalScrollView 
                android:layout_width="match_parent" 
                android:layout_height="wrap_content" 
                android:fillViewport="true" 
                android:scrollbars="none" >
                <FrameLayout 
                    android:id="@android:id/tabcontent"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent" >
                    <LinearLayout
                        android:id="@+id/tabdata"
                        android:orientation="vertical"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:gravity="center_horizontal" />
                    <TableLayout
                        android:id="@+id/myTableLayout"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:background="#33B5E5" />
                </FrameLayout>
            </HorizontalScrollView>
        </ScrollView>
  </LinearLayout>
</TabHost>
于 2012-04-25T03:03:22.577 に答える