Tag: xml

How to put two EditText in the same line

I would like to ask you, how can I put two EditText on the same line?

How to make my TextView width half of its parent?

If I want to make my TextView width exactly equal to the width of its parent, I can use android:layout_width=”fill_parent” What about if I want to make it half the width of the part? Or, in general, set the width relative to the parent’s width? Edit: I am using Relative Layout My screen looks like […]

Android Studio 1.2.1.1 layout preview problems

After updating to Android Studio 1.2.1.1, I created a new fresh blank project and created a layout.xml Shortly after creation, I decided to look at the preview. I went in and I saw this: The following classes could not be instantiated: – android.support.v7.internal.widget.ActionBarOverlayLayout (Open Class, Show Exception, Clear Cache) Tip: Use View.isInEditMode() in your custom views […]

What is character 0x1f?

I’ve just imported a chunk of text into a string element for a book app and I’m getting this error : An invalid XML character (Unicode:0x1f) was found in the element content of this document. I looked it up here http://lwp.interglacial.com/appf_01.htm and the description says US (removing underlining doesnt seem to work). What is this […]

RecyclerView item width layout_width=“match_parent” does not match parent

I’m using RecyclerView and I’m trying to make the width item of RecyclerView match_parent since I’m using LinearLayoutManager.HORIZONTAL <android.support.v7.widget.RecyclerView android:id=”@+id/listOffersHits” android:layout_width=”match_parent” android:layout_height=”match_parent” /> custom_layout.xml <?xml version=”1.0″ encoding=”utf-8″?> <android.support.v7.widget.CardView xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:card_view=”http://schemas.android.com/apk/res-auto” android:id=”@+id/card_view” android:layout_width=”match_parent” android:layout_height=”match_parent” android:layout_gravity=”center” android:layout_weight=”1″ android:layout_margin=”2dp” card_view:cardCornerRadius=”2dp”> <ImageView android:id=”@+id/offerImage” android:layout_width=”match_parent” android:layout_height=”match_parent” android:background=”@drawable/item_selector” android:scaleType=”fitXY” android:src=”@drawable/offer” /> </android.support.v7.widget.CardView> LayoutManager LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity(),LinearLayoutManager.HORIZONTAL, false); listOffersHits.setLayoutManager(linearLayoutManager); ViewHolder […]

How to programmatically reference <string> in xml file in android

I am new to android programming and wanna know this: I have 3 strings defined in the strings.xml file: <resources> <string name=”one”>First Click </string> <string name=”two”>Second Click </string> <string name=”three”>Third Click </string> <resources> and a text view which displays the first string in the strings.xml file. i don’t want to use settext(“******”) to change the […]

Android Background Image in XML File

I currently have an application which has the default black background for every slide. What I would like to do is alter the XML files to have a background image. I’m assuming there is a simple command for this but haven’t been able to find exactly what I’m looking for. I want an image to […]

Drawable resource from custom attribute

Is there any possibility to get resource from drawable folder right in some custom attribute, so i can write: <com.my.custom.View android:layout_height=”50dp” android:layout_width=”50dp” … my_custom:drawableSomewhere=”@drawable/some_image” /> and then simple perform action with drawable inside my custom view class?

String types not allowed (at 'id' with value ' @id/bAdd')

I am getting an error saying String types not allowed (at ‘id’ with value ‘ @id/bAdd’) I’ve cleaned the project. Everything was working earlier, I don’t what happened, causing this error. <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:tools=”http://schemas.android.com/tools” android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:orientation=”vertical” > <TextView android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:layout_centerHorizontal=”true” android:layout_centerVertical=”true” android:text=”Your total is 0″ android:textSize=”45dp” android:layout_gravity=”center” android:gravity=”center” android:id=”@+id/tvDisplay” tools:context=”.StartingPoint” /> <Button android:layout_width=”250dp” […]

border of items of listview in android

I want to set border of Edittext and items of listview as in the picture : My xml code is as following : <LinearLayout android:background=”#BDD6E0″ android:layout_height=”wrap_content” android:layout_width=”match_parent” android:orientation=”vertical” > </LinearLayout> <LinearLayout android:background=”#BDD6E0″ android:layout_height=”wrap_content” android:layout_width=”match_parent” android:orientation=”vertical” > <TextView android:id=”@+id/textView1″ android:layout_width=”match_parent” android:layout_height=”wrap_content” android:layout_weight=”1″ android:text=”Search” android:textColor=”#000000″ android:background=”#FFFFFF” android:textAppearance=”?android:attr/textAppearanceLarge” /> <EditText android:id=”@+id/search_pat_edit” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:singleLine=”true” android:textColor=”#000000″ android:layout_weight=”4″> </EditText> </LinearLayout> […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.