Reputation: 313
I would like to add every time I push ADD button (see the red circle) create a runtime ROW with 2 Edittext and 1 ImageButton, I use a PNG image, but when I try to create a transparent background the result is or a gray image or a white image (see the yellow arrow)...
When
this is the runtime code for add the ROW
ImgBtAdd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
LayoutInflater layoutInflater = (LayoutInflater) appContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View addView = layoutInflater.inflate(R.layout.rrow_ing, null);
AutoCompleteTextView et_ing = (AutoCompleteTextView) addView.findViewById(R.id.et_ingrediente);
EditText et_qty = (EditText) addView.findViewById(R.id.et_qty);
et_ing.setAdapter(adapter);
//textOut.setText(et_ing.getText().toString());
final ImageButton ImgBtClear = (ImageButton ) addView.findViewById(R.id.imgBt_clear);
//ImgBtClear.setBackgroundColor(Color.TRANSPARENT); //don't work
//ImgBtClear.setBackgroundResource(0); //don't work
ImgBtClear.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((LinearLayout)addView.getParent()).removeView(addView);
listAllAddView();
}
});
//ImgBtClear.setOnClickListener(thisListener);
IngContainer.addView(addView);
listAllAddView();
}
});
This is the XML for the ROW
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputLayout
android:id="@+id/input_name"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/input_qty"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<AutoCompleteTextView
android:id="@+id/et_ingrediente"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/txt_ingrediene"
android:text=""
android:inputType="text"
app:errorEnabled="true"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/input_qty"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@+id/imgBt_clear"
android:layout_toStartOf="@+id/imgBt_clear"
>
<android.support.design.widget.TextInputEditText
android:id="@+id/et_qty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/txt_quantita"
android:text=""
android:inputType="number|numberDecimal"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/input_qty"
android:layout_toEndOf="@+id/input_qty"/>
</android.support.design.widget.TextInputLayout>
<ImageButton
android:id="@+id/imgBt_clear"
android:layout_width="60dp"
android:layout_height="wrap_content"
app:srcCompat="@drawable/directory_up"
android:scaleType="centerInside"
tools:ignore="ContentDescription"
android:focusable="false"
android:layout_alignParentRight="true"
android:baselineAlignBottom="true"
android:layout_alignBottom="@+id/input_qty"
android:background="#00000000" //don't work
android:background="@null" //don't work
android:background="@android:color/transparent" //don't work
android:layout_alignParentTop="true"/>
</RelativeLayout>
I have tried different method:
android:background="#00000000" //don't work
android:background="@null" //don't work
android:background="@android:color/transparent" //don't work
if I use the android:background this is the result if I remothe the code the result is:
I used this code for the ADD button and works fine android:background="#00000000"
I compile with this parameter:
compileSdkVersion 25
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.bandweb.myviewrecipes"
minSdkVersion 16
targetSdkVersion 23
Upvotes: 0
Views: 398
Reputation: 5550
In your ImageView you must use android:src
not app:srcCompat
, So:
Change this:
app:srcCompat="@drawable/directory_up"
With this:
android:src="@drawable/directory_up"
Upvotes: 1