2011-11-20 4 views
0

그림과 같이 tabView를 만들고 싶습니다.이미지처럼 tabView를 만드는 방법

enter image description here

그라데이션 탭 내가

를 클릭 한 사람이다하지만 난

http://www.androidhive.info/2011/08/android-tab-layout-tutorial/

예를

이처럼되고 싶지 않는 것은 내에서 생성 될 수 있다는 것이다. XML? 어떤 도움을 주시겠습니까?

편집 : .XML 코드

<ImageButton 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:background="@drawable/header" 
     android:layout_weight="1" 
      /> 

    <ImageButton 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:background="@drawable/header_btn1"  
     />   

    <ImageButton   
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:background="@drawable/header_btn2" 
     /> 

    <ImageButton 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:background="@drawable/header_btn3" 
     /> 
</LinearLayout> 

답변

2

내가 안드로이드에서 실제 "탭"구성 요소를 사용하지 않을 것입니다. 원래 탭이있는 모든 프로젝트에서 탭을 제거한 버튼을 사용하여 모든 것을 자체 활동으로 만들었습니다.

나는 다음과 같이 뭔가를 할 것이다 :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:orientation="vertical"> 

    <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="80dp" 
      android:orientation="horizontal" 
      android:background="#000000"> 
     <LinearLayout 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:orientation="vertical" 
       android:layout_weight="1" 
       android:background="#68cffa"> 
      <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="hello" 
        android:layout_gravity="center_horizontal|center_vertical"/> 

     </LinearLayout> 
     <FrameLayout 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="#68cffa"> 
      <ImageView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="@drawable/star"/> 
      <ImageView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="@drawable/highlight" 
        android:id="@+id/star1" 
        android:visibility="gone"/> 
     </FrameLayout> 
     <FrameLayout 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="#68cffa"> 
      <ImageView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="@drawable/star"/> 
      <ImageView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="@drawable/highlight" 
        android:id="@+id/star2" 
        android:visibility="gone"/> 
     </FrameLayout> 
     <FrameLayout 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="#68cffa"> 
      <ImageView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="@drawable/star"/> 
      <ImageView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="@drawable/highlight" 
        android:id="@+id/star3" 
        android:visibility="gone"/> 
     </FrameLayout> 

    </LinearLayout> 


</LinearLayout> 

은 스타의 이미지 당신이 전체 파란색 블록에 대해 원하는 너비/높이를 확인하고 투명 별 주위를 둡니다. 현재 사용중인 탭을 기준으로 강조 이미지 표시/숨기기

+0

감사합니다. mate.i가 동일한 작업을 수행했지만이 작업이 신뢰할 수있는 방법인지 확인하고 싶습니다. 감사합니다. –

+0

감사합니다. 첫 번째 탭의 "hello"텍스트가 중간에 숨겨져 있고 "hel"만 보입니다. 어떻게 수정합니까? 내 .xml 코드 위의 답변에 게시하십시오. –

+0

첫 번째 이미지 버튼이 공간을 'layout_weight'로 지정하십시오. 당신은 정말로 그것을 원하지 않습니다. 바깥 쪽 레이아웃에 이미지가 포함되고 그 안의 이미지가 플로트되고 레이아웃이 늘어납니다. 그런 이유로 내 코드에 추가 LinearLayout이 있고 그 안에 TextView가 있습니다 (TextView 대신 ImageView를 사용하는 것처럼 보이지만 같은 원칙이 적용됩니다). –

관련 문제