Android Spinner Customised design - android

Are there any possibilites to utilise spinner customized designs like the below picture?
this is my spinner xml
<Spinner
android:id="#+id/service"
android:layout_width="match_parent"
android:textColor="#000"
android:layout_height="wrap_content" />
I'm interested in achieving this with Android.

First: You need an image say "spinner_bg.png", like this.
Second: Set this image as background to you spinner like this.
<Spinner
android:id="#+id/service"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/spinner_bg"
android:textColor="#000" />
Hope this helps you.

Related

Android: Custom Spinner xml

I'm New to Android and want to customize the spinner in an app I'm making.
This is what I want my spinners to look like http://prntscr.com/bk4pbt. I tried setting the background of the spinner to an image of the shape but it not looking how i want it to be.
<TextView
android:id="#+id/textViewStore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:text="Store:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/text" />
<Spinner
android:id="#+id/store_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:prompt="#string/store_prompt" />

How to use setHint() in autocompletetextview programmatically in android

I am using a autocompletetextview in my app.I want to set hint in this by code.Is it possible?
Used Xml code is..
<AutoCompleteTextView
android:id="#+id/autoCompletedTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="50dp"
android:background="#android:color/transparent"
android:singleLine="false"
android:textColor="#color/text_white"
android:textSize="#dimen/text_size12sp" />
code is........
autocompleted.setHint(getResources().getString(R.string.select_pickuplocation));
Yes it is possible and easy. Try with this...
autoCompleteTextView.setHint("Your Hint");
One way is with xml
<AutoCompleteTextView
android:id="#+id/autoCompleteTextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignRight="#+id/passwordEntry"
android:ems="10"
android:text=""
android:hint="Test" />
Other way is programatically
autoCompleteTextView1.setHint("YourHint");
and if you want to set Text from your strings resources you can do it like this:
autoCompleteTextView1.setHint(getResources().getString(R.string.yourString));
Hope to help!
If you want to display hint at the bottom of the matching list, use setCompletionHint. If you want to use normal hint, use setHint.

how to make list views like google io 2014 app in android?

I want to create a list view layout with a image and title in it. I want a layout like listview in google io 2014 app. It should be a tiled listview with some colour till the image gets loaded, after the image is loaded it should be shown in the upper half of the listview and title should be shown below with some background colour. I am attaching the screenshot of google io app here.
Updated: If somebody can point me some template custom layout for this listview it would be helpful!
Create a custom list with all the needed controls in separate layout and inflate it using a custom adapter you can find a small example here
you could create a custom layout something like this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:background="#drawable/images"
android:layout_height="match_parent"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#862c10">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#android:color/white"
android:textSize="15sp"
android:layout_marginLeft="10dip"
android:textStyle="bold"
android:text="HTML5 everywhere how and why android users use the webplatform" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#android:color/white"
android:textSize="15sp"
android:layout_marginLeft="10dip"
android:layout_marginTop="10dip"
android:text="Wed 5 2001" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#android:color/white"
android:textSize="15sp"
android:layout_marginLeft="10dip"
android:layout_marginTop="10dip"
android:text="Steven roberts and mark robinson " />
</LinearLayout>
</LinearLayout>
(this should not be the answer, but forgive me I could not add a comment, and actually I hope this will give him the answer).
First of all I guess you didn't get on well with using ListView and Adapter in Android. So I suggest you to read the following article first:
ListView tutorial 1
ListView tutorial 2
They will teach you how to use xml to define your custom row view. Then you will know how to use George Thomas's xml. Try how to implement the getView() method.

Custom Spinner TextView is being cut off

So in the attached screen shot and the code sample you can see my custom spinner. As you can see my text is getting cut off no matter what I try to do. The nine patch image is set up correctly with the text padding on it too. I have right just about everything and am at a complete loss...
Custom spinner
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/spinner"
android:textColor="#555"
android:textSize="22sp"
android:textStyle="bold"
android:typeface="normal"
android:layout_width="wrap_content"
android:layout_height="40sp"
android:gravity="center_vertical|left"
android:singleLine="true" />
Implementing custom spinner
<Spinner
android:id="#+id/spinner_both20"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/b_both20"
android:layout_alignTop="#+id/b_both20"
android:layout_marginLeft="4sp"
android:layout_marginRight="5sp"
android:layout_toRightOf="#+id/b_both20"
android:background="#drawable/buttons"
android:padding="20sp" />
Java
ArrayAdapter<CharSequence> aBoth = ArrayAdapter
.createFromResource(getActivity().getApplicationContext(),
R.array.d20both, R.layout.spinner_settings)
I'm super frustrated to be spending this many hours on something so simple. Any help would rock!
Padding will cut cut into your inner text.

Android: Making EditText similar to Chrome's URL box

I'm making chatting application for my school's assignment.
In my opinion, the default EditText in Android does not looks good. I want to make it looks like the URL box in Android's Chrome:
I have seen this design used in other applications such as Catch Notes (which looks beautiful).
So, is there any built-in option to change the EditText or we must draw it from scratch? Can anyone give link? I tried googling it, but I don't know the correct term
Thanks
you can achieving this by doing edittext background transparent.
so put your image in background of your layout and take a edittext inside this. and make edittext transpernt..
or
try this
<EditText
android:id="#+id/tracknumbertxt"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_toLeftOf="#+id/info"
android:background="#drawable/enter_tracking_no"
android:ems="10"
android:hint="Enter Tracking No."
android:paddingLeft="30dp"
android:inputType="text"
android:imeOptions="actionGo"
android:singleLine="true" >
</EditText>
here i have assign padding left..
so as per your design you have to set paddingRight property instead of paddingLeft..
Blindly use below layout style..
You will have your layout ready. Just replace the button backgrounds and your are done.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#android:color/darker_gray"
android:padding="5dip"
android:gravity="center">
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1"
android:background="#android:color/white"
android:gravity="center"
android:padding="5dip">
<EditText android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Type URL"
android:layout_weight="1"
android:background="#android:color/transparent"/>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Refresh"/>
</LinearLayout>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="btn1"/>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="btn2"/>
</LinearLayout>
There is nothing native to the SDK that can make it look like that. (maybe if you restrict use to only a certain version of the OS, then you can use that version's default styling, but isn't really a viable solution)
You will need to create an image to use as a background for the EditText to make it look how you want. The best options for text boxes and things like that are to either use a 9-patch image, or to create a layer-list XML file and describe your design that way. Either way, the file would go in the res/drawable folder in the project and you would set it as the background like so:
<EditText android:id="#+id/et_whatever"
android:layout_width="match_parent"
android:layout_height="wrap_content"
background="#drawable/YOUR_FILE_NAME" />

Categories

Resources