2012-04-09 36 views
0

嗨,我試圖重新創建這個按鈕樣式更具體的'查看籃'按鈕。 waitrose app該按鈕需要有多行文本,每個文本的文本大小和字體顏色等不同。多內襯多風格按鈕

以下是目前的代碼。我已經正確創建了按鈕及其顯示,但是當您點擊它時,按下的狀態不起作用。我哪裏錯了。提前致謝。

XML按鈕文件:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 

    android:state_pressed="true" 
    android:state_focused="true" 
    android:background="@drawable/button_bg" > 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Some Text" 

    android:state_pressed="false" 
    android:state_focused="false" 
     android:textColor="#ffffff" /> 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Some Text" 

    android:state_pressed="false" 
    android:state_focused="false" 
     android:textColor="#ffffff" /> 

</LinearLayout> 

java file code: 


    package com.buttons2; 

    import com.buttons2.R; 

    import android.app.Activity; 
    import android.os.Bundle; 
    import android.widget.Button; 

    public class Buttons2Activity extends Activity { 
     /** Called when the activity is first created. */ 
     @Override 
     public void onCreate(Bundle savedInstanceState) { 
      super.onCreate(savedInstanceState); 
      setContentView(R.layout.main); 

      Button button = (Button) findViewById(R.id.button1); 
      setContentView(R.layout.button); 


     } 
    } 

回答

0

我想你可能會需要編寫一些代碼來處理文本&圖片的點擊,並用它來專門設置主,容器的選擇/未選擇狀態查看(顯示正確的按下按鈕狀態)。