2014-05-11 3 views
0

내 질문을 명확히하기 위해 : 나는 tablayout에 tablayows가있다. 각 테이블 행에는 텍스트보기 만 있습니다.안드로이드 : 프로그래밍 방식으로 tablerow 배경의 너비를 설정하는 방법

내가 원하는 것은 tablerow의 배경을 특정 tablerow의 진행 막대로 사용하는 것입니다. 근본적으로 진행 막대를 tablerow의 배경으로 사용하는 방법이 있습니까?

+0

ProgressBar 클래스를 확장하여 앞에 ProgressBar 클래스를 추가하여 텍스트를 추가 할 수 있습니다. 여기에 [예]가 있습니다. (http://weavora.com/blog/2012/02/23/android-progressbar-with-text/)이보기를 TableRow에 놓고 필요에 따라 조정하십시오. – Garret

+0

ProgressBar를 사용하지 않으려는 경우 프로그래밍 방식으로 ImageView를 사용하여 셀의 배경으로 너비를 설정할 수 있습니다. [이 예제] (http://stackoverflow.com/questions/4811905/android-how-to-programmatically-set-width-of-imageview-inside-tablerow?rq=1). – Garret

답변

0

두 가지 옵션이 마음에 와서 :

예를 들어

, 여기에 카메라 미리보기로 만든 샌드위치, (처음에 보이지 않는) 반투명 층 및 그 아이 위에 그려 상대 레이아웃입니다 :

  1. ProgressBar 클래스를 확장하여 앞에 추가 할 수 있습니다. example. TableRow에이보기를 배치하고 필요에 따라 조정하십시오.

  2. ImageView로 셀의 배경으로 너비를 프로그래밍 방식으로 설정할 수 있습니다. 이 예는 here입니다.

# 2는 가장 간단한 것으로 보이고 추가 수업이없는 것 같습니다.

+0

감사합니다. 옵션 1이 더 나은 선택이되었습니다. 하하. 나는 어떤 이유로 2 번 옵션을 찾아 낼 수 없었다. – NeoMime

0

FrameView으로 두 번째보기를 가질 수 있습니다. 첫 번째보기는 배경으로 사용되며 두 번째보기는 투명한 배경으로 그 위에 그려집니다.

<FrameLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <SurfaceView 
     android:id="@+id/camera_preview" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_centerInParent="true" /> 

    <View 
     android:id="@+id/transparency" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:background="#80000000" 
     android:visibility="invisible" 
     /> 
    <RelativeLayout 
     android:id="@+id/ontop" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     > 
     ... 
    </RelativeLayout> 
</FrameLayout> 
관련 문제