我有一個問題滾動條在我的佈局。 我的佈局包含一個包含兩個佈局的滾動條。第一個佈局具有靜態高度。第二個拉特包含tabHost爲tabgroup。第二個佈局也包含Expandable Gridview。ScrollView從tabbar開始,但需要從佈局的頂部滾動
問題是,我加載我的佈局時,,它直接顯示Tabbar並隱藏第一個佈局。我們可以滾動但最初我需要顯示頂部佈局,而不是tabHost。任何人都可以幫我解決這個問題嗎?
在此先感謝...
我加入了從XML文件我的代碼段。
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/header"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<RelativeLayout
android:id="@+id/relay1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true" >
<include
android:id="@+id/cover"
android:layout_width="match_parent"
android:layout_height="wrap_content"
layout="@layout/coverphoto" />
<ImageView
android:id="@+id/ximg_logo"
android:layout_width="70dip"
android:layout_height="70dip"
android:layout_below="@+id/cover"
android:layout_marginLeft="16dip"
android:layout_marginTop="-42dip" />
<TextView
android:id="@+id/xtxt_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/ximg_logo"
android:layout_marginLeft="5dip"
android:layout_toRightOf="@+id/ximg_logo"
android:ellipsize="end"
android:ems="5"
android:singleLine="true"
android:textColor="@color/sixty_black"
android:textSize="20sp" >
<requestFocus />
</TextView>
<Button
android:id="@+id/xbtn_follow"
style="@style/follow_button_normal"
android:layout_width="95dip"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/cover"
android:layout_marginRight="7dip"
android:background="@drawable/buttons_shape_fill_orange"
android:text="@string/str_follow" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/cover"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="@color/fifty_black"
android:orientation="vertical"
android:paddingLeft="3dip"
android:paddingRight="3dip"
android:weightSum="3" >
<RelativeLayout
android:id="@+id/xlay_following"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_alignParentTop="true"
android:layout_marginTop="10dip"
android:layout_weight="1"
android:onClick="following" >
<TextView
android:id="@+id/xtxt_imfollowing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textColor="@color/white"
android:textSize="18sp" />
<TextView
android:id="@+id/xtxt_imfollowing_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/xtxt_imfollowing"
android:layout_centerHorizontal="true"
android:padding="5dip"
android:text="@string/str_im_following"
android:textColor="@color/white"
android:textSize="14sp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/xlay_follower"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:onClick="follower" >
<TextView
android:id="@+id/xtxt_myfollower"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dip"
android:textColor="@color/white"
android:textSize="18sp" />
<TextView
android:id="@+id/xtxt_myfollowers_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/xtxt_myfollower"
android:layout_centerHorizontal="true"
android:padding="5dip"
android:text="@string/str_myfollowers"
android:textColor="@color/white"
android:textSize="14sp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/xlay_interests"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_alignParentBottom="true"
android:layout_below="@+id/xlay_follower"
android:layout_centerHorizontal="true"
android:layout_weight="1" >
<TextView
android:id="@+id/xtxt_interests"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dip"
android:textColor="@color/white"
android:textSize="18sp" />
<TextView
android:id="@+id/xtxt_interests_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/xtxt_interests"
android:layout_centerHorizontal="true"
android:paddingBottom="5dip"
android:text="@string/str_interest"
android:textColor="@color/white"
android:textSize="14sp" />
</RelativeLayout>
</LinearLayout>
<RelativeLayout
android:id="@+id/xrl_msg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="@color/fifty_black"
android:padding="10dip" >
<ImageView
android:id="@+id/ximg_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/ic_msg" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/relay2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/relay1"
android:layout_marginTop="10dip" >
<TabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dip" >
</TabWidget>
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="@color/orange" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/tab1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:id="@+id/tab2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:id="@+id/tab3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
</RelativeLayout>
</RelativeLayout>
</ScrollView>
我認爲它有幫助,如果你只是發佈完整的佈局,除非它太大,希望沒有。 – 2015-02-24 09:59:04
我需要從上到下滾動。所以我認爲「match_parent」不是寬度問題。在Height中,我只給了wrap_content。我有我的第二個佈局tabHost。這可能是我的問題。如果我使用tabHost,則滾動位置從tabHost移開。請爲我提供一些示例,它應該包含佈局下面的佈局,它應該包含tabHost與gridView項目 – 2015-03-02 07:32:05
嗨,我已經更新了我的佈局xml ...你能建議我一個解決方案? – 2015-03-02 07:58:02