2014-06-18 3 views
0

많은 셀 안에 큰 텍스트를 표시해야하는 일정을 개발 중입니다. 단추에 하루의 숫자를 나타내는 텍스트가 있습니다. 어떻게 다른 textView를 첨부 할 수 있습니까? 그 안에?단추 안에 여러 TextViews를 추가하는 방법

+3

'내가 넌 못하지 Button' 내부에 여러 TextViews을 추가 할 수있는 방법. 버튼이 컨테이너가 아닙니다. 대신 GridView를 사용해보십시오. –

답변

0

버튼에 TextView를 추가 할 수 없습니다. 할 수있는 일은 레이아웃 (Relative/Linear/Frame/etc)을 사용하여 Textviews를 캡슐화하는 것입니다. 그런 다음 레이아웃에 onClickListener를 설정합니다!

당신의 XML은 다음과 같이 보일 것입니다 :

<RelativeLayout> 
    <TextView/> 
    <TextView/> 
    ... 
</RelativeLayout> 

은 물론, 당신은 그것을에 속성을 추가해야합니다. 또한 onClickListener를 RelativeLayout (또는 원하는 레이아웃)으로 설정하십시오!

+0

답변 해 주셔서 감사합니다. :)하지만 버튼의 텍스트가 필요합니다 :(하지만 내가 언급 한 버튼은 이미 텍스트 (하루의 숫자) –

0

버튼을 FrameLayout으로 묶은 다음 FrameLayout 내에 텍스트 뷰를 추가 할 수 있습니다. 텍스트가 bringToFront를 사용하여 시도되지 않는 경우()

레이아웃 :

<FrameLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      app:layout_constraintLeft_toLeftOf="parent" 
      app:layout_constraintRight_toRightOf="parent" 
      android:id="@+id/button_frame" 
      > 
     <Button 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@drawable/button_border" 
      android:gravity="center" 
      android:onClick="onClick" 
      android:text="@string/get_more" 
      android:id="@+id/get_more" 
      android:stateListAnimator="@null" 

     /> 

      <TextView 
       android:id="@+id/linearTimer" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:gravity="center" 
       android:layout_gravity="right" 
       android:padding="10dp" 
       android:text="123" 
      > 
    </FrameLayout> 

활동 :

countDownView = (TextView) findViewById(R.id.linearTimer); 

countDownView.bringToFront(); 
관련 문제