0

My app works just fine when I use a color code for my Buttons background in my layout. Something like:

android:background="#ff6699"

But it stops working when I replace the color code with my drawable:

android:background="@drawable/blue_background_round_corners" 

This means, there is obviously something wrong with my drawable. Any idea what? My drawable:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
    <shape>
        <solid android:color="#ff6699"></solid>
        <corners android:radius="10dp"/>
    </shape>
</item>

</selector>

by the way, I am using data binding. My fragment:

public class MainFragment extends Fragment {
FragmentMainBinding binding;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    binding = DataBindingUtil.inflate(inflater, R.layout.fragment_main, container, false);
    View v = binding.getRoot();
    v.setClickable(true);
    v.setFocusable(true);
    return v;
}
}
FNZ
  • 27
  • 1
  • 1
  • 6
  • If by "stops the app", you mean that the app is crashing, use Logcat to examine the stack trace associated with the crash: https://stackoverflow.com/questions/23353173/unfortunately-myapp-has-stopped-how-can-i-solve-this – CommonsWare Dec 30 '18 at 14:36
  • Your drawable' s code is working fine. – forpas Dec 30 '18 at 14:37
  • Are you intentionally using a `StateListDrawable` using `selector` ? –  Dec 30 '18 at 15:28

0 Answers0