سؤال

First post here so apologize in advance for any mistakes.

I am trying to add some buttons as an overlay to a camera preview, and everything is working as expected except that the buttons get transparent no matter what I try when I want them to be opaque.

This is how I inflate the layout:

LayoutInflater inflater = getLayoutInflater();
View controls = inflater.inflate(R.layout.test, null);
LayoutParams layoutParamsControl = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
this.addContentView(controls, layoutParamsControl);

And this is how the xml file for the controls look like:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <Button
            android:id="@+id/button_capture"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|center_horizontal"
            android:text="Capture" />

        <Button
            android:id="@+id/button_mapview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|right"
            android:text="Map" />

    </FrameLayout>

</LinearLayout>

My question is does anyone know why my buttons become transparent and how to fix it?

هل كانت مفيدة؟

المحلول

Try to add color as background like android:background="#ffffff" and accordingly add the text color which will be visible like android:textColor="#000000".

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top