android-layout

Set ImageView Size Programmatically in DP Java

时光怂恿深爱的人放手 提交于 2020-02-06 05:07:12
问题 I want to set the width and height of an ImageView in Android . The ImageView does not exist in XML . It is created here: public void setImageView(int i,Integer d, LinearLayout layout ) { ImageView imageView = new ImageView(this); imageView.setId(i); imageView.setPadding(2, 2, 2, 2); imageView.setImageBitmap(BitmapFactory.decodeResource(getResources(), d)); imageView.setScaleType(ImageView.ScaleType.FIT_XY); layout.addView(imageView); } And it is placed into this LinearLayout :

Multiple layers of shadows in android recyclerview elevation

筅森魡賤 提交于 2020-02-06 04:16:49
问题 I have a recyclerview with an elevation of 8dp, transparent background and bounds as outlineProvider. clipToPadding is set to false on the parent relativelayout. I am facing a weird issue w.r.t the shadow cast by the recyclerview elevation. The shadow seems to cover up the edges of the recyclerview or there is an extra layer between the relativelayout and the child recyclerview (Attached an image reference). What is actually causing this effect? I have searched a lot but could not find any

is dp really device independent?

て烟熏妆下的殇ゞ 提交于 2020-02-06 04:07:48
问题 This sounds stupid , but I have confusion. I have defined a layout which have a stripe of images . Strip height is set as some x dp. But I can see difference in height , in difference phones (in samsung note2 it looks bigger than nexus 4). Can someone explain or provide some useful links ? Thanks in advance. 回答1: FYI, DP stands for Density independent pixel . And Here is definition of Screen density: Screen density The quantity of pixels within a physical area of the screen; usually referred

Prevent EditText from going to new line when 'Space' is tapped

前提是你 提交于 2020-02-05 04:32:12
问题 I want to have an EditText which is multi Line and First Letter of a Sentence to be capital. I'm using: <EditText android:id="@+id/editText2" android:layout_width="300dp" android:layout_height="150dp" android:layout_alignParentStart="true" android:layout_alignParentTop="true" android:layout_marginStart="32dp" android:layout_marginTop="67dp" android:background="#ddebed" android:ems="10" android:inputType="textMultiLine|textCapSentences" android:singleLine="false" android:text="@string/same" />

Spannable text is too wide for TextView

谁说胖子不能爱 提交于 2020-02-04 07:34:50
问题 I have a TextView with the font sans-serif-light . To link some words inside, I set a text as a Spannable like this: final Spannable text = new SpannableString(textView.getText()); final Matcher matcher = PATTERN_TAG.matcher(text); while (matcher.find()) { text.setSpan(span, startIndex, endIndex, 0); } textView.setText(text); textView.setMovementMethod(LinkMovementMethod.getInstance()); The Span that I apply sets the word's font to sans-serif-medium like this: public abstract class

Spannable text is too wide for TextView

家住魔仙堡 提交于 2020-02-04 07:31:31
问题 I have a TextView with the font sans-serif-light . To link some words inside, I set a text as a Spannable like this: final Spannable text = new SpannableString(textView.getText()); final Matcher matcher = PATTERN_TAG.matcher(text); while (matcher.find()) { text.setSpan(span, startIndex, endIndex, 0); } textView.setText(text); textView.setMovementMethod(LinkMovementMethod.getInstance()); The Span that I apply sets the word's font to sans-serif-medium like this: public abstract class

Android : Error Snack bar not showing correctly with Map View

ⅰ亾dé卋堺 提交于 2020-02-04 07:17:46
问题 this is xml layout <android.support.design.widget.CoordinatorLayout android:id="@+id/map_location_picker_main_content" android:layout_width="match_parent" android:layout_height="match_parent"> <com.mapbox.mapboxsdk.maps.MapView android:id="@+id/map_view" android:layout_width="match_parent" android:layout_height="match_parent" /> </android.support.design.widget.CoordinatorLayout> and this is the output : I am using a CoordinatorLayout as a root of my xml file and mapbox layout for showing the

ListView is showing gapes in list items Android

醉酒当歌 提交于 2020-02-04 04:54:27
问题 i am trying to implement listView through setListAdapter and Efficient Adapter. I want that when list is show then the background should not be repeat. My code is repeating the whole layout of list.xml due to which my list item are showing with so much gap. Right now my list is working like that: But i want this type of view: Here is my editText.xml in which i type the word and a list View is opened. <EditText android:id="@+id/start_edit" android:layout_width="match_parent" android:layout

How to get a android ListView item selector to use state_pressed

笑着哭i 提交于 2020-02-04 04:15:30
问题 I want to color to background of an image View when it get pressed. I tried to do it with selector that changes the image for the different states (pressed and not pressed). The problem now is that the image replaces the previous with the exact same size and I want it be to much larger. I use a custom layout that implements checkable, and I tried also to overload the onCreateDrawableState function, but it never being called. Help please.. This is how it looks: before pressing: after pressing:

Android Studio app works in emulator but not on a real device

梦想与她 提交于 2020-02-04 02:48:06
问题 I am new to android programming and have been having a lot of trouble with it. I finally got my app to work in the emulator on both API 23 and 16 my target is API 16. It runs with no problems on the emulators but when I try to use it on my phone (Google Nexus 5 API 23) <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match