Trying to get buttons to fill height

This commit is contained in:
Neale Pickett 2012-12-08 16:45:58 -07:00
parent f1b8ebeaa1
commit e8caffd1fa
4 changed files with 34 additions and 30 deletions

View File

@ -11,4 +11,4 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target. # Project target.
target=android-15 target=android-4

View File

@ -1,20 +1,14 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main" android:id="@+id/main"
android:layout_height="fill_parent" android:layout_width="fill_parent"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:keepScreenOn="true"> android:orientation="vertical">
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" <Button
android:id="@+id/mainTable" android:id="@+id/pause"
android:layout_height="fill_parent" android:text="Jam End"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:gravity="center" android:layout_height="0dp"
android:stretchColumns="*"> android:layout_weight="1"
<TableRow> android:onClick="pauseButton" />
<Button android:text="@+string/jam_end" </LinearLayout>
android:id="@+id/pause"
android:layout_span="2"
android:onClick="pauseButton" />
</TableRow>
</TableLayout>
</ScrollView>

View File

@ -37,19 +37,18 @@ public class PenaltyTimer extends Activity
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
Persistence p = (Persistence)getLastNonConfigurationInstance(); Persistence p = (Persistence)getLastNonConfigurationInstance();
TableLayout tl;
View top;
long now = SystemClock.uptimeMillis(); long now = SystemClock.uptimeMillis();
LinearLayout top;
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.main); setContentView(R.layout.main);
tl = (TableLayout)findViewById(R.id.mainTable); top = (LinearLayout)findViewById(R.id.main);
top = findViewById(R.id.main);
// Create all the buttons
for (int i = 0; i < 4; i += 1) { for (int i = 0; i < 4; i += 1) {
TableRow tr = new TableRow(this); LinearLayout tr = new LinearLayout(this);
tl.addView(tr, i); top.addView(tr, i);
for (int j = 0; j < 2; j += 1) { for (int j = 0; j < 2; j += 1) {
TimerButton b; TimerButton b;
@ -75,28 +74,30 @@ public class PenaltyTimer extends Activity
b.running = p.running[idx]; b.running = p.running[idx];
} }
v = b.getButton(); tr.addView(b.getButton());
tr.addView(v);
tbs[i*2 + j] = b; tbs[i*2 + j] = b;
} }
} }
// Invert value, then simulate a button press // Invert value, then simulate a button press
if (p != null) { if (p != null) {
paused = ! p.paused; paused = ! p.paused;
} else { } else {
paused = true; paused = true;
} }
pauseButton(top); pauseButton();
jbs[0].setOther(jbs[1]); jbs[0].setOther(jbs[1]);
jbs[1].setOther(jbs[0]); jbs[1].setOther(jbs[0]);
mHandler.postAtTime(pulse, 100); mHandler.postAtTime(pulse, 100);
} }
public Object onRetainNonConfigurationInstance() { public Object onRetainNonConfigurationInstance() {
Persistence p = new Persistence(); Persistence p = new Persistence();
int i; int i;
@ -125,7 +126,7 @@ public class PenaltyTimer extends Activity
} }
public void pauseButton(View v) { public void pauseButton() {
Button e = (Button) findViewById(R.id.pause); Button e = (Button) findViewById(R.id.pause);
paused = !paused; paused = !paused;
@ -142,5 +143,9 @@ public class PenaltyTimer extends Activity
e.setText(R.string.jam_end); e.setText(R.string.jam_end);
} }
} }
public void pauseButton(View v) {
pauseButton();
}
} }

View File

@ -10,6 +10,7 @@ import android.graphics.PorterDuffColorFilter;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.os.SystemClock; import android.os.SystemClock;
import android.os.Vibrator; import android.os.Vibrator;
import android.util.TypedValue;
import java.util.*; import java.util.*;
public class TimerButton public class TimerButton
@ -43,6 +44,10 @@ public class TimerButton
this.now = now; this.now = now;
} }
public void setHeight(int height) {
b.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24);
}
public long remaining() { public long remaining() {
if (running) { if (running) {
return duration - (now - startTime); return duration - (now - startTime);