android-layout

Call requires API level 16 (current min is 14)

不羁的心 提交于 2021-01-04 04:17:31
问题 I have this line in my code: linearLayout.setBackground(drawable); setBackground() shows the following error: Call requires API level 16 (current min is 14) What does this mean? Can I raise my API level? What does a higher/lower API level mean? Does it limit the amount of devices my app can be used on if the API level is higher? 回答1: What does this mean? It means that the setBackground(Drawable) method was added in API Level 16, and older devices do not have it. However, your app's

CardView rounded corner gets unexpected white colors

强颜欢笑 提交于 2021-01-03 05:47:30
问题 When using rounded corner in CardView, shows a white border in rounded area which is mostly visible in dark environment. For easier understanding, check the attached image blow. here is xml <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/colorTransparent" android:orientation="vertical" android:padding="4sp"> <androidx.cardview.widget.CardView android:id="@+id/image_view_container" android:layout_width="match_parent" android

Create ImageView that is round, so click will work on round area only android

喜你入骨 提交于 2020-12-30 06:59:06
问题 Hi I am creating tabla App, For example It should not respond outside of round but ImageView is Rectangle so it is responding I am sure you can understand this problem ImageView is rectangle but it's image is round, but I want to detect click only on round image... 回答1: Thank you for your all support, based on your support I have done by below way and it is working perfect ImageView imgView = (ImageView) findViewById(R.id.imageView1); imgView.setOnTouchListener(new View.OnTouchListener() {

ViewModel cannot be instantiated in an Activity

巧了我就是萌 提交于 2020-12-30 06:19:54
问题 I am trying to instantiate one ViewModel to use across all of my Activity(s). public class LaunchActivity extends Activity { private Controller control; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_launch); control = ViewModelProviders.of(this).get(Controller.class); } } but I got an error at control = ViewModelProviders.of(this) <-- stating that it cannot resolve of(this) , but based on the example here by

How to auto-resize imageview for different screen sizes android studio?

落爺英雄遲暮 提交于 2020-12-30 03:14:17
问题 I am starting to develop apps for android devices using Android Studio. While I was testing my app for screen size compatibilty I noticed that the imageviews do not auto-resize. The imageview placement looks completely different in different screen sizes. If the screen is small enough, the imageview will sometimes be placed outside of the viewscope. I have looked all over the internet but I am a little confused on how to make the app compatible with most screen sizes (not including tablets).

How to auto-resize imageview for different screen sizes android studio?

半腔热情 提交于 2020-12-30 03:12:49
问题 I am starting to develop apps for android devices using Android Studio. While I was testing my app for screen size compatibilty I noticed that the imageviews do not auto-resize. The imageview placement looks completely different in different screen sizes. If the screen is small enough, the imageview will sometimes be placed outside of the viewscope. I have looked all over the internet but I am a little confused on how to make the app compatible with most screen sizes (not including tablets).

How to auto-resize imageview for different screen sizes android studio?

為{幸葍}努か 提交于 2020-12-30 03:03:52
问题 I am starting to develop apps for android devices using Android Studio. While I was testing my app for screen size compatibilty I noticed that the imageviews do not auto-resize. The imageview placement looks completely different in different screen sizes. If the screen is small enough, the imageview will sometimes be placed outside of the viewscope. I have looked all over the internet but I am a little confused on how to make the app compatible with most screen sizes (not including tablets).

How to swipe one row of RecyclerView programatically (at run time)?

半城伤御伤魂 提交于 2020-12-29 13:22:52
问题 I have a RecyclerView with items inside like this: I use ItemTouchHelper.SimpleCallback to listen for swipe and onChildDraw() to draw a canvas when items are swiped: A bit more swipe: My problem: I want to simulate a swipe (at run time) just on first item inside the list of items; I need first item to go (more or less ) -100 px on its X axis and then go back to original position. How to achieve this? 回答1: I created some utility method in case someone needs it import android.animation

Changing layout managers for different views in RecyclerView

佐手、 提交于 2020-12-28 20:51:03
问题 I implemented an expandable recyclerview with child elements that are part of the list. I followed this code. This is how it works, The implementation of ExpandableListView using RecyclerView is briefly described as follows. The list model has an additional parameter "type" that identifies whether the item is a header or child. By checking this parameter, the adapter inflates view and viewholder corresponding to the type. If the type is HEADER, it will inflate the layout of header item, that

Changing layout managers for different views in RecyclerView

左心房为你撑大大i 提交于 2020-12-28 20:46:06
问题 I implemented an expandable recyclerview with child elements that are part of the list. I followed this code. This is how it works, The implementation of ExpandableListView using RecyclerView is briefly described as follows. The list model has an additional parameter "type" that identifies whether the item is a header or child. By checking this parameter, the adapter inflates view and viewholder corresponding to the type. If the type is HEADER, it will inflate the layout of header item, that