skip to Main Content

Android Studio – Why I can't find by id XML image

public class MainActivity extends AppCompatActivity { ListView listView; Button buttonForCP; ImageView img; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); buttonForCP =(Button) findViewById(R.id.buttonForCP); img = findViewById(R.drawable.ic_img);//this problem // |||||||||||||||||||||||||| buttonForCP.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { buttonForCP.setBackground(img); }…

VIEW QUESTION

Android Studio – Image View doesn't match parent's rounded cornered background

<FrameLayout android:id="@+id/flTodayTraining" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="@dimen/fl_today_training_bg_margin_bottom" android:layout_marginTop="@dimen/fl_today_training_bg_margin_top" android:layout_marginHorizontal="@dimen/fl_today_training_bg_margin_horizontal" android:background="@drawable/today_training_bg" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@id/tvDaysTrained" > <androidx.appcompat.widget.LinearLayoutCompat android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <ImageView android:layout_width="match_parent" android:layout_height="@dimen/iv_today_training_detail_height" android:src="@drawable/male_upper_body" android:scaleType="fitXY" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/upper_body" android:textSize="@dimen/tv_today_training_detail_text_size" android:textColor="@color/black" android:paddingVertical="@dimen/tv_today_training_detail_padding_vertical" android:gravity="center" /> </androidx.appcompat.widget.LinearLayoutCompat> </FrameLayout> That's the cornered background of the…

VIEW QUESTION

Android Studio – Why the button doesn't get all the attributes from xml

I have created a xml file called round_button. It's a simple circular button with a gradient. Here is the simple code <?xml version="1.0" encoding="utf-8"?> <shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android"> <corners android:radius="3000dip" /> <gradient android:type="linear" android:startColor="#8dbab3" android:endColor="#0DCAAC" /> </shape> And that's the output:…

VIEW QUESTION
Back To Top
Search