android-xml

How to add id to public.xml?

二次信任 提交于 2019-11-27 20:20:14
In my project, I needed to set always-constant IDs to Views. I mean IDs that are constant between different app builds. After some investigation I found that it can be achieved by using values/public.xml and any id declared in that file would not change on future builds. Now the problem is that I can't define an id of a view in some layout file. This is my layout.xml containing an ImageView with an Id which should be added to public.xml: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android

Android Cannot resolve symbol '?attr/selectableItemBackground'

冷暖自知 提交于 2019-11-27 19:57:41
<android.support.v7.widget.CardView android:id="@+id/card_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/card_outer_padding" android:layout_marginTop="@dimen/card_outer_padding" android:layout_marginRight="@dimen/card_outer_padding" android:layout_marginBottom='@{model.cardBottomMargin}' android:foreground="?attr/selectableItemBackground" android:onClick="@{model::onCardClick}" app:cardElevation="2dp" app:cardCornerRadius="2dp" app:cardUseCompatPadding="true"> </android.support.v7.widget.CardView> I got this error message Cannot

Android: Placing ImageView on overlap between layouts

最后都变了- 提交于 2019-11-27 19:53:37
I am trying to place an ImageView on the overlap point between two layouts. In the picture below, my goal would be to place the ImageView where the white square is. NOTE: The overlap point will not necessarily be centered vertically as shown below Is this possible in XML? My only guess right now is to do this in the actual code itself. EDIT 8/3/2016: For reference, I think ConstraintLayouts may be the best future solution for these types of problems http://tools.android.com/tech-docs/layout-editor This will do what you want, with either an image of fixed height, or calculated programatically.

what's wrong with hardcoded string in android xml file?

爷,独闯天下 提交于 2019-11-27 19:23:14
问题 I love to put simple text directly on the xml file without declaring a string first. It is easier, more simple and less messy. However, it always has a warning badge whenever I do so. What if I have a dozens of hardcoded string in my xml file without concerning the warning? Will I get into a trouble? thanks in advance. 回答1: No, you will not get into trouble, but using @string/yourString in your xml will be a good practice and it will make multi-language support easier. 回答2: When you use hard

Android card view has thin gray line in between cards

谁说我不能喝 提交于 2019-11-27 18:31:50
问题 I have an android List view which shows card-like views, and as you can see in this picture, there is a thin gray line between my cards: How can I get rid of the gray line? My xml to achieve this card view is like this: <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"

Android XML: android:elevation vs. app:elevation

南楼画角 提交于 2019-11-27 17:26:35
问题 When do I use android:elevation and when app:elevation ? What's the difference between those two? 回答1: Hope I can help, Let's talk with an example: <android.support.design.widget.FloatingActionButton android:layout_height="wrap_content" android:layout_width="wrap_content" ... android:elevation="@dimen/elevation_medium" /> The android:elevation attribute will work from the API level 21 and upper. <android.support.design.widget.FloatingActionButton android:layout_height="wrap_content" android

android.support.v4.widget.SwipeRefreshLayout working but it is not visible

倖福魔咒の 提交于 2019-11-27 15:53:22
I am using a SwipeRefreshLayout to refresh the content. The problem is that it is working, but is not visible while swiping down. Here's how I have SwipeRefreshLayout in xml file: <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout 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="match_parent" android:fitsSystemWindows="true" tools:context="com.abc.xyz.MainActivity"> <android.support.design

How do I clear ListView selection?

扶醉桌前 提交于 2019-11-27 14:48:34
TL;DR: You choose an option from (a) my listview. Then, you change your mind and type something in (b) my edit text. How do I clear your listview selection and only show your edittext? (and vice versa) I have an application with a listview of options as well as an edittext to create an own option. I need the user to either choose or create an option, but not both. Here's a drawing of my layout: Whenever the user selects an option from the listview, I set it as "selected" by making it green, like so: <?xml version="1.0" encoding="utf-8" ?> <selector xmlns:android="http://schemas.android.com/apk

Android CalendarView slowing down layout

删除回忆录丶 提交于 2019-11-27 14:39:38
问题 This is driving me crazy. I have a fragment in my Android app which is laid out using a RelativeLayout. Problem is that for some reason it takes ages to render, about 5 seconds just to load about 4 elements on screen. One of the elements is a CalendarView and when I remove it it goes back to proper speeds (ie: instant). I'd imagine the problem is got to do with the way I'm asking Android to lay it out, must not make much sense or is inefficient or something. Here's the XML file: <?xml version

How rotate line in Android XML?

こ雲淡風輕ζ 提交于 2019-11-27 14:38:06
问题 I'm trying to draw a diagonal line in an Android app with the XML, but it is not working. It simply draws a horizontal line. main.xml : <RelativeLayout 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_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal