가로 스크롤 가능한 탭을 구현하는 방법은 무엇입니까?
-
13-12-2019 - |
문제
이 응용 프로그램을 구현하려고합니다.현재 탭이 설계되었으며 7 개 이상의 탭이 있기 때문에 너무 혼잡 해 보입니다.Tabwidget이 가로로 스크롤 할 수 있도록 어떻게 설계 할 수 있습니까?나는 시장에서 몇 가지 앱 에서이 디자인을 보았지만 내 앱에서 이것을 구현하는 방법은 어떨까요?
하나의 응용 프로그램을 사용하는 앱은 자체적으로 스크롤되는 수평 ScrollView가 있었고 특정 이미지 / 버튼을 누르면 일부 콘텐츠가 표시됩니다.그것은 내가 추측하는 탭으로 보이지 않았다.
아무도 이것에 대한 아이디어가 있습니까?
해결책
Jake Wharton의 ViewPager 앱을 확인하십시오.그것이 당신이 필요로하는 정확히 일입니다.라이브러리 프로젝트이므로 프로젝트에 포함시켜야합니다.
다른 팁
Tableayout android 디자인 라이브러리
<android.support.design.widget.TabLayout
android:id="@+id/categories"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:tabMode="scrollable" />
. HorizontalScrollView를 사용하여 꽤 좋은 예입니다. http://java.dzone.com/articles/scrolling-tabs-Android
<HorizontalScrollView
android:id="@+id/vTabs"
android:scrollbars="none"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:background="@color/main_color_gray_dk"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:enabled="false"
android:id="@+id/tab1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/popular" />
<View
android:id="@id/view1"
android:layout_width="@dimen/pad_1dp"
android:layout_height="fill_parent" />
<Button
android:id="@id/tab2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/newest" />
<View
android:id="@id/view1"
android:layout_width="@dimen/pad_1dp"
android:layout_height="fill_parent" />
<Button
android:id="@id/tab3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/distance" />
<View
android:id="@id/view1"
android:layout_width="@dimen/pad_1dp"
android:layout_height="fill_parent" />
<Button
android:id="@+id/tab4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/minimum" />
</LinearLayout>
</HorizontalScrollView>
.
텍스트를 맛으로 변경하십시오. RelatVelayout 및 AlignTopaRentBottom="TRUE" 희망이
에 도움이됩니다이 링크를 확인하십시오 : "Nofollow"> https://dzone.com/articles/scrolling-tabs-Android
가로 링크보기와 탭 세트로 Tabwidget을 랩으로 랩합니다. 화면의 너비를 넘어서고 사용자가 드래그 할 수 있습니다. 필요한 경우 왼쪽 및 오른쪽 탭 :
<?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="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <HorizontalScrollView android:layout_width="fill_parent" android:layout_height="wrap_content" android:fillViewport="true" android:scrollbars="none"> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content"/> </HorizontalScrollView> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </LinearLayout></TabHost>
.