Multi lined Multi styled button
Posted
by
user1321811
on Stack Overflow
See other posts from Stack Overflow
or by user1321811
Published on 2012-04-09T17:25:53Z
Indexed on
2012/04/09
17:29 UTC
Read the original article
Hit count: 510
Hi i'm trying to recreate this button style more specifically the 'view basket' button. waitrose app The button needs to have multiple lines of text each with a different text size and font colour etc.
Here's the code so far. I've created the button and its displays correctly but when you click on it the state pressed isn't working. Where am I going wrong. Thanks in advance.
xml button file:
<?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);
}
}
© Stack Overflow or respective owner