背景与我的天文台重叠

时间:2015-10-27 19:36:03

标签: css button overlap chronometer

我放了一个秒表png,我正在尝试设计它但是当我放置天文台时我看不到它超出了图像。颜色不是问题因此它没有融入。我尝试使计时器的背景与图像相同但仍然没有。一旦我将它从图像中移开,我就会看到它,但不是我想要的地方。

<Chronometer
        android:id="@+id/chronometer"
        android:format="%s"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="40sp"
        android:textColor="#ffffff"
        android:background="@drawable/stopwatch2"
        android:layout_alignTop="@+id/my_button"
        android:layout_alignLeft="@+id/my_button"
        android:layout_alignStart="@+id/my_button" />
    <Button
        android:id="@+id/my_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/stopwatch2"
        android:text=" "
        android:layout_marginTop="71dp"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true" />

MAIN ACTIVITY


public class MainActivity extends AppCompatActivity {
Chronometer mChronometer;

private int loop = 0;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    setClick();
}

public void setClick() {
    Button button;

    mChronometer = (Chronometer) findViewById(R.id.aChronometer);

// Watch for button clicks.
    button = (Button) findViewById(R.id.stopWatch);
    button.setOnClickListener(mStartListener);

    button = (Button) findViewById(R.id.stopWatch);
    button.setOnClickListener(mStartListener);

    button = (Button) findViewById(R.id.stopWatch);
    button.setOnClickListener(mStartListener);
}

View.OnClickListener mStartListener = new OnClickListener() {
    public void onClick(View v) {
        if (loop == 0) {
            mChronometer.setBase(SystemClock.elapsedRealtime());
            mChronometer.start();
            loop++;
        } else if (loop == 1) {
            mChronometer.stop();
            loop++;
        } else if (loop == 2) {
            mChronometer.setBase(SystemClock.elapsedRealtime());
            loop = 0;
        }
    }
};

0 个答案:

没有答案