I really like the androi 4 settings page and im trying to style my app the same way.
Here is a screenshot: http://cdn.androidtapp.com/wp-content/uploads/2011/10/Android-4.0-Settings-Screen.jpg.
Ive just gotten into java and android 3 or 4 days ago so style i havent really focused on style and dont know anything about it so i have a couple of questions:
1) How to set similar caption to list (Wiress and network on the picture for example)
2) How to set the same colors to my app? Is this somekind of a default style?
3) Is padding used on the picture to make list distance from borders? Can padding be applied thought whole application or does it have to be defined in every xml?
Thank you!
Yes you can apply a universal style to your app (this includes padding), it's quite straightforward
look here for a starting point http://developer.android.com/guide/topics/ui/themes.html
If you want to style your app the same, you should follow these guidelines about standard metrics and grids:
http://developer.android.com/design/style/metrics-grids.html
1) To set a similar caption you have to implement your own customized view and add it to your list.
2) You can set a theme you need in AndroidManifest.xml or you can use standard items. To find them have a look at android.jar/res.layout folder in your Android library in your project. There are all the standard layout files for Views.
3) What you need is to set margins in your layout-file.
You have to make a layout file and specify all the View-elements and margins in it.
However, if you want to make preferences there are ready classes available for that (PreferenceActivity or PreferenceFragment).
Related
Im developing an Android app in Java using Android Studio. I have a layout called activity_way_bill, where it must show a list of trips. Also, I have a layout called item_waybill_trip, where I have labels for displaying the trips details.
I need to insert X item_waybill_trip layouts into the activity_way_bill layout (the X number I will know at runtime). Right now, I just have it included like this, in the XML file:
<include android:id="#+id/trip" layout="#layout/item_waybill_trip" />
But this is a static solution and only allows me to include 1 (or a predefined number) of layouts. I need to include X, and set different texts for each one. How can I do this?
If you want to display the list of element with the same layout but different data than you have to use recycle view.
You can also define the count at runtime and change the count if you needed.
You can visit the site below and check how to use recycle view. :-
https://developer.android.com/guide/topics/ui/layout/recyclerview
As mentioned in the answer by #Mahavir Jain you could use a recyclerview for that but if you want to go the other way, you will have to create the dynamic layouts at runtime and add them to the parent layout using the .addView() method of the parent layout
If your app needs to display a scrolling list of elements based on large data sets (or data that frequently changes), you should use RecyclerView as described on this page.
I want to create Menu like this. Tap on any Item it will open Submenu with Items
I don't think there exists a library which will allow you to do this. (I may be wrong).
But according to me the best possible way to achieve this would be to use two tableViews placed next to each other and updating the the data for the second tableView on didSelectRow of the first tableView. You would have manage a few complexities but it is achievable.
If you only have 2 level of details in your menu, you could also use one tableView, show the 1st level elements in the section header, and create rows on section header click (using a button or tap) for the second level elements.
Edit:
My answer mentions some iOS naming conventions. Because it was originally asked for iOS with tag iOS and swift. I decided not change the original answer because the core concept of achieving this should be similar on both platforms.
Anyways, I think you can still do same stuff for android, just use list view where I mentioned tableView
Good evening all.
I've created an app using AIDE, which I'll ultimately get set up with google to sell on the play store.
I'm presently working through the differences between portrait and landscape/horizontal.
Presently, my app's main page doesn't allow the whole page to show when I rotate the phone to horizontal. It only shows a single line. And if I try to scroll, it doesn't allow that (not entirely a surprise, because I didn't set it up for scrolling).
My header/intro line is set to sp=30. My subsequent lines are set to sp=20.
I've been looking at how to deal with this issue. I.e., I want the text to resize when the orientation is changed from portrait to landscape. I have already found the androidmanifest screenOrientation="fullUser" code to allow for full rotation. This however does not deal with my real issue--- screen resizing, and text resizing, based on orientation.
I've been reading some older posts on here discussing
get textview()
but my lack of experience in coding is now asking--- where am I suppose to place those code snippets? Would they go on mainActivity.java, and main.xml or new/different pages?
And with newer API's, is there a better/more-efficient way to do this? The articles I'm reading are 3 years old at the newest.
TYIA.
SteveB.
I want the text to resize when the orientation is changed from portrait to landscape
You're looking for how resource quantifiers work.
You can make a res/layout-land or res/values-land folder explicitly defining landscape resources.
Your options include
use number or #dimen or #style in layout xml files for android:textSize
use number or #dimen to define #style in styles.xml over a TextAppearance parent style's textSize
define #dimen value in dimens.xml
I'm new to Java and Android. I have been trying for the past week to make an app for my phone. The app consists of 4 pages, which are diagrammed below:
Page 1: Contains a picture taking up the size of the screen. If I click on the picture it needs to go to "page 2".
Page 2: Consists of an icon on the left (say the flag for instance) followed by a text field (eg. USA). When "USA" strip is clicked it needs to go to page 3.
Page 3: Consists of text, picture and then more text from a string. This page needs to correspond to the strip clicked on in page 2 ("USA" in this example). There are also two buttons at the bottom of "page 3" and "page 4" which when pressed need to go to the corresponding page numbers.
Page 4: This page is displayed if the "More" button is pressed on "page 3".
I would like this phone to work on a minimum Android 2.2 or 2.3. All logos, pictures and string texts need to be locally available (resources folder) and not website based. I have tried all sorts of combinations of ListView's and buttons with OnClickListener's as well as toast screens. My limited knowledge of programming is frustrating.
My question is if there is a template around which will help me out with this app? Or if there are any web resources.
In Android, individual "pages" or "screens" can be implemented as Activitys. You need to extend the Activity class and add the components that you wish to display. Most of the layout can be done in an XML file. I strongly suggest that you google for a tutorial that illustrates the basics of Android programming. From there, you can start by creating an app with two pages. And then just keep adding a little bit at a time until you get the complete app that you want.
There some easy ways to do this. If you want to be backwards compatible to SDK 8 you can do this in two ways. You can use Fragments or Activities for each layout. If you implement fragments, I suggest reading http://developer.android.com/guide/components/fragments.html inside there you will about using the FragmentActivity instead of the Activity. Read this link http://developer.android.com/tools/extras/support-library.html as it will have the needed libraries to implement the Fragments in older versions of the SDK. It does looks like you looking for some navigation buttons that reside on the bottom of the layout. In order to fully implement a layout that has this view on the bottom of the screen in SDK 8, you will need to create your own View and place it on the bottom of the screen. RelativeLayout and alignParentBottom = "true" will accomplish this. There is also a way to do this using a ViewPager which will also work in the backwards compatibility requirements you have. I am sorry the amount of information I am throwing at you but I really would recommend looking into other questions posted by users on this topic. How to navigate to another page in android? for example. Good luck and everything you are looking for is able to be learned through a Google search. Maybe not all at once.
I'm creating an app for use by pilots. It mostly uses TextView, EditText, Button, etc. In other words, not very graphics-heavy.
When used at night, I'd like for the user to be able to switch to a "night mode" where everything on screen is red and black... like the Google Sky Map app. (This is important for pilots because the color red does not destroy the eye's natural night vision adaptation as other colors do.)
What's the best way to do this? I found APIs like ColorFilter, etc. but I'm not sure how I'd apply these app-wide.
If you're simply talking about changing the colours of the various views within the layout and not the structure of the layout itself, then I'd suggest you simply do this using styles.
i.e. Define two sets of styles for the various views which make up your layout - one set for night mode and one for day mode. In your activity, it then becomes a case of calling setStyle() on each of your views to toggle it between night and day.
Coming up with a sensible naming convention and parentage scheme for your styles will make your life a lot easier. e.g. MyText.Large vs MyText.Large.Night.
The Android developer doc on Themes and Style is a good starting point.
Creating a day and night theme and setting it programmatically would work. But it also requires you to duplicate your styles, just to specify different drawables/colors.
Instead, you can maintain one style and use Android's built in day/night mode support. Just as you can have multiple variations of a single layout (for landscape or portrait screen orientations,) drawable (for different pixel densities) and string (for different locales,) you can also have day and night versions of your drawables and colors. The specifiers are "-night" and "-notnight" but you will probably want to use "-night" or nothing, making your day version the default. For example:
res/drawable/fancy-button-background.9.png
res/drawable-night/fancy-button-background.9.png
Android should be able to switch the day/night mode automatically but the details on how and when that happens are a little unclear to me. To change the mode yourself, you can use UiModeManager#setNightMode(). Just make sure car mode is enabled first, using enableCarMode(0).