i want to make application in android Tablets like in ipad which have spliting screen,
How i can do that ? if any body have idea please send me!
Thank you in advance.
This is achievable using the Fragments API. Fragments are available since Android 3.0, but there's also a Support Library that lets you use these API's from Android 1.6. Hope this helps.
Using fragments: check http://mobile.tutsplus.com/tutorials/android/android-compatibility-working-with-fragments/
it's a tutorial with sample application that uses the compatibility package (allows you to support from API 4), it may help
this is not a 'feature' limited to iOS
you can easily do this in Android by using two vertical LinearLayouts and assigning them equal weight - to split the screen into half or Different weights to achieve something like the image you provided.
And of course, there are a lot of other ways to do that.
This will be the fragment xml file. then you have to write two xml files for CustomerList(Left Part) and CustomerInfo(Right Part). your activity should extends FragmentActivity. try with this:::
<fragment class="ui.misc.Customers$CustomerList"
android:id="#+id/customerlistfragmant" android:layout_weight="1"
android:layout_width="550px"
android:layout_height="wrap_content"
/>
<fragment class="ui.misc.Customers$CustomerInfo"
android:id="#+id/customerinfofragmant" android:layout_weight="1"
android:layout_width="350px" android:layout_height="wrap_content" />
<FrameLayout android:id="#+id/regscreentwo" android:layout_weight="1"
android:layout_width="0px"
android:layout_height="fill_parent"
/>
</LinearLayout>
you can use the APIs described here: Fragments API
Related
<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_parent"
android:gravity="center"
android:orientation="vertical"
tools:context="com.bignerdranch.android.geoquiz.CheatActivity">
<TextView
android:id="#+id/answer_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="24dp"
tools:text="Answer"/>
I am a novice in programming. I started with Big Nerd Ranch programming book. I came across this code. In the book it is stated as:
"This namespace allows you to override any attribute on a widget for the
purpose of displaying it differently in the Android Studio preview. Since TextView has a text attribute,
you can provide a literal dummy value for it to help you know what it will look like at runtime. The
value “Answer” will never show up in the real app. Handy!"
What does that actually mean? I am completely new. I know this is foolish question, please help me in this.
Thanks to that line
xmlns:tools="http://schemas.android.com/tools"
you can use in all your XML something like that
tools:text="Answer"
Thanks to that line
xmlns:android="http://schemas.android.com/apk/res/android"
you can use in all your XML element the android attribute, for example
android:id="#+id/answer_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="24dp"
The book you're reading is a good book, keep continue and don't give up!
Tools is basically a collection of extra properties you can add to your TextView that assist you when designing layouts in Android Studio. In this particular example, tools:text allows you to put a fake value into your TextView which will only show up in the the layout preview in Android Studio.
This will allow you to see what a TextView looks like when designing your layout in Android Studio, but you don't have to worry about removing that dummy text from your layout when you build a "real" version of your app for a phone.
See also: Tools Attribute Reference
I am using ViewPager with PagerTabStrip:
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.PagerTabStrip
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"/>
</android.support.v4.view.ViewPager>
And I would like to accomplish my tabs to look like this as Google recommends:
I have two tabs and I would like for each of them to be fixed and take 50% of the screen. I was looking through the options in XML and programmatically and can't find anything useful.
How can I accomplish that? Thank you.
I'm not sure about android.support.v4.view.PagerTabStrip. But you can use alternative library for getting this effect, i use it in my one project and it works well. After you add the lib to your project, set pstsShouldExpand to true
You should use android.support.design.widget.TabLayout instead of PagerTabStrip.
I feel so dumb asking this, but I couldn't find the answer nowhere. I'm used to C# and XAML, but I'm getting started with Android Developement, so I'm new with Java and XML and I feel so lost.
What is the control that's closest to the WPF Grid?
How can I define it via code and XML?
Well, another possible solution is to use LinearLayout and then set layout_weight of child elements as required, but make sure to set layout_height of child elements to 0dp.
For Example:
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".5" />
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:text="SomeText"
android:layout_weight=".5"/>
</LinearLayout>
You are probably looking for GridLayout, which is explained in full with implementation examples in this blog post.
Note that GridLayout was first introduced in API 14, Ice Cream Sandwich. If you need to support older devices, you can use the Support Library equivalent, android.support.v7.widget.GridLayout which as its package name implies, supports back to API 7. You'll need to add the support GridLayout to your project by following these instructions.
So I received a graphic interface for an application I'm building. It has some images and texts and the images are set in a specific way, and some text goes inside or on top some images.
In the android project I opened I get the default activity which is RelativeLayout, but it's hard to set all the elements exactly where they should be with the designer and editing the XML directly seems like a pain.
I also see that elements that I add always "align" to something or right/left to some other element - but what I really want to do is place them at a specific location (so the end result will be the same as the design I got). If I was building it for the web I would have used absolute positions.
What is the correct way to go about this in android?
Thanks
EDIT
I managed to start implementing some elements of the design in a manner that makes them look ok on the eclipse Graphical Layout and on my device.
Is this XML ok - or am I using it wrong:
<ImageView
android:id="#+id/imgClouds"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:contentDescription="#string/layout_activity_main_imgClouds"
android:scaleType="centerCrop"
android:src="#drawable/clouds_ltr" />
<ImageView
android:id="#+id/imgBaby"
android:layout_below="#+id/imgClouds"
android:layout_width="50dp"
android:layout_height="52dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="5dp"
android:layout_marginTop="75dp"
android:contentDescription="#string/layout_activity_main_imgBaby"
android:src="#drawable/baby" />
<ImageView
android:id="#+id/imgBubble"
android:layout_toLeftOf="#+id/imgBaby"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="false"
android:layout_alignParentTop="false"
android:layout_marginLeft="56dp"
android:layout_marginTop="-5dp"
android:layout_marginRight="5dp"
android:src="#drawable/bubble_ltr" />
</RelativeLayout>
This is primarily opinion based, but there's certain things most android developers will agree, "Absolute Position" is not an option in Android, because of the OS Nature like Fragmentation in Device Screen Sizes/Densities, having an absolute position of the elements will lead to a crappy app, it will look good only in the device you are using and chances are that all the other devices will not look as you expect, you really need to look at the android design patterns and best practices to avoid a terrible GUI implementation, RelativeLayout is the best way to go, in android you must learn to love it...
Also the sooner you get used to work with XML directly in layouts will be better for you, most IDEs that help out with this functionality end up adding a lot of unnecessary code, once you go through the learning curve to build layouts using XML it totally worth it.
Hope it helps!
Regards!
How to add a header to an existing android activity? All the examples that I found with a search engine are showing how to add a header to the list view.
I don't know what you are looking for..might be this answer is useful to you.
You have to add a view the xml that you're using for your layout. So for example, say your Activity is using a linear layout. You'd do:
<LinearLayout android:orientation="vertical" ....>
<LinearLayout....>
<!---- Header Stuff Goes Here ---->
</LinearLayout>
<!--- Rest of the layout for your activity goes here ---->
</LinearLayout>
What you are looking for is a ActionBar, it is included on 3.0 api but if you want to use with backward compatibility you can use different libraries, my preferit is GreenDroid you can also see an example downloading the GreenDroid Catalog App from Market.
I hope this helped you :)