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
# Project target.
target=android-15
target=android-4

View File

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

View File

@ -37,19 +37,18 @@ public class PenaltyTimer extends Activity
@Override
public void onCreate(Bundle savedInstanceState) {
Persistence p = (Persistence)getLastNonConfigurationInstance();
TableLayout tl;
View top;
long now = SystemClock.uptimeMillis();
LinearLayout top;
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tl = (TableLayout)findViewById(R.id.mainTable);
top = findViewById(R.id.main);
top = (LinearLayout)findViewById(R.id.main);
// Create all the buttons
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) {
TimerButton b;
@ -75,28 +74,30 @@ public class PenaltyTimer extends Activity
b.running = p.running[idx];
}
v = b.getButton();
tr.addView(v);
tr.addView(b.getButton());
tbs[i*2 + j] = b;
}
}
// Invert value, then simulate a button press
if (p != null) {
paused = ! p.paused;
} else {
paused = true;
}
pauseButton(top);
pauseButton();
jbs[0].setOther(jbs[1]);
jbs[1].setOther(jbs[0]);
mHandler.postAtTime(pulse, 100);
}
public Object onRetainNonConfigurationInstance() {
Persistence p = new Persistence();
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);
paused = !paused;
@ -142,5 +143,9 @@ public class PenaltyTimer extends Activity
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.os.SystemClock;
import android.os.Vibrator;
import android.util.TypedValue;
import java.util.*;
public class TimerButton
@ -43,6 +44,10 @@ public class TimerButton
this.now = now;
}
public void setHeight(int height) {
b.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24);
}
public long remaining() {
if (running) {
return duration - (now - startTime);