Changing screen content from Navigation Drawer - Java for Android App Development

I am creating app with navigation drawer. There are a lot of examples of creating such apps, but all examples show only how to change one framgent, I mean that activity has only one main fragment with content.
Here is example of such layout from offical docs.
Code:
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- The main content view -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- The navigation drawer -->
<ListView android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:background="#111"/>
</android.support.v4.widget.DrawerLayout>
In this case we are replacing content of content_frame layout with another fragment.
But in my case, I have two fragments on my activity, here is my layout.
Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/toolbar_actionbar"
layout="@layout/toolbar_default"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar_actionbar">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/first_fragment"
/>
<View
android:layout_width="fill_parent"
android:layout_height="10dp"
android:background="@android:color/darker_gray"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/second_fragment"
>
</FrameLayout>
</LinearLayout>
<!-- android:layout_marginTop="?android:attr/actionBarSize"-->
<fragment
android:id="@+id/fragment_drawer"
android:name=".NavigationDrawerFragment"
android:layout_width="@dimen/navigation_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
app:layout="@layout/fragment_navigation_drawer"/>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
So in my case I have two fragment containers for holding differen fragments.
SO I am writing here to get some advices what approach should I follow in this case.
Create wrapper for two fragments ? And this two layouts will be nested.
Change two fragments if it is required.
Open new activity each time user clicks on item in NavDraw menu ?
Something other ?
Some options in NavDraw menu will open new activity, because it has quite different interface and logic, but there are some screens that can be displayed with the help of replacing fragment.
Also my first_fragment will be present on most pages, so maybe it will be acсeptable way to updating UI in my case.
I want to follow all UI design and building app approaches in order to create responsive app.
Please suggest what is the most acceptable way to implement this.
Thanks in advance.

Related

[Q] ListView doesn't use fill_parent

I have made a sidebar and want to display little screenshots in the sidebar. The ListView contains a LinearLayout with an ImageView. The ListView should take the full screen height, but it is only as big as one item. How must I change the xml to get the ListView using full screenheight?
Thanks in advance
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/firstlin"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<HorizontalScrollView android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:scrollbars="none">
<LinearLayout android:id="@+id/LinearLayout03"
android:layout_width="fill_parent"
android:orientation="horizontal"
android:layout_height="fill_parent">
<ScrollView android:id="@+id/ScrollView01"
android:padding="10dip"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="#D8D8D8"
android:scrollbars="none">
<LinearLayout android:id="@+id/LinearLayout09"
android:layout_width="wrap_content"
android:orientation="vertical"
android:layout_height="fill_parent">
<ListView android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
</ScrollView>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
I dont understand why you have a scrollview. A listview scrolls. You have 2 moving parts
Thank you
I didn't no that a listview scrolls - i removed the scrollview, now everythink work.
Kotake

how to get AdMob ads to show up at the top of my screen.

I've got AdMob working in my app, but it's showing up at the bottom of my screen. Does anyone know how to force it to the top of the screen? I don't wont to use RelativeLayout as I already have a bunch of stuff set up with my LinearLayout.
I'm initiating AdMob via an @id reference in my main.xml and some calls in the java activity:
Code:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/linearLayout" .....this is the only line I added for my Admob reference
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center">
<ImageView android:id="@+id/ImageView01"
android:src="@drawable/image01"
android:layout_height="150dp"
android:layout_width="200dp"
android:scaleType="centerCrop"
android:paddingTop="10px">
</ImageView>
</LinearLayout>
Bla, Bla, Bla...more layout stuff
Then I have this in my java activity...
Code:
setContentView(R.layout.main);
//create an adView
LinearLayout layout = (LinearLayout)findViewById(R.id.linearLayout);
String pubID = "a14d9cfd23d60cf";
AdView adView = new AdView(this, AdSize.BANNER, pubID);
layout.addView(adView);
AdRequest request = new AdRequest();
//request.setTesting(true);
adView.loadAd(request);
Never mind...I got it figured out. It's all about where you place the layout id. If I move android:id="@+id/linearLayout" down into the LinearLayout just below the one it's in now, My ad shows at the top.

Ask Your Mother, Ask Your Father...

I have successfully managed to incorporate orientation changes into the Ticker Display!!! However, my part/know-how is done with... The coding for the rotation is in there, and it works great, however I need modified XML Layouts for the main Ticker display in LANDSCAPE... I wouldn't even know where to begin...
So basically, I would like it if when the phone is put into landscape, the main ticker display goes into landscape also! So, your job is here... Either you figure it out, or ask around, if you can take the main ticker display (standbymode.xml in framework-res.apk) and rotate it....
Right now, I have it set as my own custom text instead Pics:
I automatically made it go back to the default vertical view when you lock the phone...
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Please help my dream come true! (P.S. I am really tired while writing this, so.... yeah... haha)
awesome job as always!
Scavanger hunt time! Ill try and make some time to look into or redirect to what I find.
Questions:
1. The layout code (<Layout> etc) needed you say are ones for whatever you want to put on that screen ie shorcuts or even a ticker apk?
2. Thus needing deminisions and actions and parameters?
I need hints lol
ciscogee said:
awesome job as always!
Scavanger hunt time! Ill try and make some time to look into or redirect to what I find.
Questions:
1. The layout code (<Layout> etc) needed you say are ones for whatever you want to put on that screen ie shorcuts or even a ticker apk?
2. Thus needing deminisions and actions and parameters?
I need hints lol
Click to expand...
Click to collapse
Thanks man! and haha, alright sounds good!
And the only thing that needs to be done is just rotating the Layouts, TextViews, and ImageViews of the main ticker Display, NOT the code for them! The code for them is already stored within the Services file, thanks to me, but they need to be properly defined! So basically, take this:
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_gravity="bottom" android:orientation="horizontal" android:id="@id/standbymode_default_vertical" android:background="@null" android:layout_width="fill_parent" android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout android:layout_gravity="top|left|center" android:id="@id/RelativeLayout01" android:layout_width="103.0px" android:layout_height="96.0px">
<ImageView android:layout_gravity="top" android:id="@id/WeatherIcon" android:layout_width="80.0px" android:layout_height="80.0px" android:layout_marginLeft="8.0px" android:layout_marginTop="8.0px" />
<ImageView android:id="@id/IconSel" android:background="@drawable/weather_press" android:visibility="gone" android:layout_width="80.0px" android:layout_height="80.0px" android:layout_marginLeft="8.0px" android:layout_marginTop="8.0px" android:layout_marginBottom="8.0px" />
</RelativeLayout>
<LinearLayout android:orientation="vertical" android:id="@id/LinearLayout02" android:layout_width="0.0dip" android:layout_height="96.0px" android:layout_weight="1.0">
<TextView android:textSize="@dimen/data.text.size" android:textStyle="bold" android:textColor="#ffffffff" android:layout_gravity="top|left|center" android:id="@id/TextView02" android:layout_width="wrap_content" android:layout_height="@dimen/data.layout.height" android:layout_marginTop="@dimen/data.layout.margin.top" android:layout_marginBottom="@dimen/data.layout.margin.bottom" />
<LinearLayout android:gravity="top" android:layout_width="fill_parent" android:layout_height="fill_parent">
<TextView android:textSize="@dimen/time.text.size" android:typeface="normal" android:textColor="@color/clockcolor" android:layout_gravity="top|left|center" android:id="@id/TextView03" android:layout_width="wrap_content" android:layout_height="@dimen/time.layout.height" android:layout_marginBottom="@dimen/time.layout.margin.bottom" />
<TextView android:textSize="@dimen/data.text.size" android:typeface="normal" android:textColor="@color/clockcolor" android:layout_gravity="top|left|center" android:id="@id/TextView04" android:paddingLeft="5.0px" android:layout_width="wrap_content" android:layout_height="@dimen/time.layout.height" android:layout_marginBottom="@dimen/time.layout.margin.bottom" />
</LinearLayout>
</LinearLayout>
<RelativeLayout android:id="@id/RelativeLayout02" android:layout_width="68.0px" android:layout_height="wrap_content">
<ImageButton android:id="@id/HistoryButton" android:background="@null" android:focusable="true" android:layout_width="68.0px" android:layout_height="wrap_content" android:src="@drawable/tt_tickerhistory_buttonup" android:scaleType="fitXY" android:layout_alignParentRight="true" />
</RelativeLayout>
</LinearLayout>
and make it for ONLY Landscape, so it is forced into that position!
Oh, and important side note for any and all developers, I cleaned up the standbymode XML, so that all of the layouts (vertical, horizontal, quick launch, sleep mode) aren't being called in the same place... Instead, they are being branched out into specific sub-XMLs... So, for the vertical view, the file where the layout is stored is now "standbymode_default_vertical." This is all just behind the scenes, nothing changes up front, but in the background it makes everything a lot neater
I haven't released the framework-res with this in it yet, (or the specific source) because it isn't really a big deal, but once I get the modified layout for the Horizontal (Landscape) view of the code above, i'll incorporate the cleaner format and the code into my new release
im on it.
ticker port question:
have u discovered all the stock ticker functions files (from the platform ie smali and xmls)? i ask because im looking at i500 gb sources and i may be able to either port the ticker into the build (but platform would also have to be ported with ticker inserted etc) or if its feasible, to just mod the gb kernel with our display specs?
try this:
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_gravity="bottom" android:orientation="horizontal" android:id="@id/standbymode_default_vertical" android:background="@null" android:layout_width="fill_parent" android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout android:layout_gravity="top|left|center" android:id="@id/RelativeLayout01" android:layout_width="103.0px" android:layout_height="96.0px">
<ImageView android:layout_gravity="top" android:id="@id/WeatherIcon" android:layout_width="80.0px" android:layout_height="80.0px" android:layout_marginLeft="8.0px" android:layout_marginTop="8.0px" />
<ImageView android:id="@id/IconSel" android:background="@drawable/weather_press" android:visibility="gone" android:layout_width="80.0px" android:layout_height="80.0px" android:layout_marginLeft="8.0px" android:layout_marginTop="8.0px" android:layout_marginBottom="8.0px" />
</RelativeLayout>
<LinearLayout android:orientation="vertical" android:id="@id/LinearLayout02" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1.0">
<TextView android:textSize="@dimen/data.text.size" android:textStyle="bold" android:textColor="#ffffffff" android:layout_gravity="top|left|center" android:id="@id/TextView02" android:layout_width="wrap_content" android:layout_height="@dimen/data.layout.height" android:layout_marginTop="@dimen/data.layout.margin.top" android:layout_marginBottom="@dimen/data.layout.margin.bottom" />
<LinearLayout android:gravity="top" android:layout_width="match_parent" android:layout_height="match_parent">
<TextView android:textSize="@dimen/time.text.size" android:typeface="normal" android:textColor="@color/clockcolor" android:layout_gravity="top|left|center" android:id="@id/TextView03" android:layout_width="wrap_content" android:layout_height="@dimen/time.layout.height" android:layout_marginBottom="@dimen/time.layout.margin.bottom" />
<TextView android:textSize="@dimen/data.text.size" android:typeface="normal" android:textColor="@color/clockcolor" android:layout_gravity="top|left|center" android:id="@id/TextView04" android:paddingLeft="5.0px" android:layout_width="wrap_content" android:layout_height="@dimen/time.layout.height" android:layout_marginBottom="@dimen/time.layout.margin.bottom" />
</LinearLayout>
</LinearLayout>
<RelativeLayout android:id="@id/RelativeLayout02" android:layout_width="wrap_content" android:layout_height="wrap_content">
<ImageButton android:id="@id/HistoryButton" android:background="@null" android:focusable="true" android:layout_width="68.0px" android:layout_height="wrap_content" android:src="@drawable/tt_tickerhistory_buttonup" android:scaleType="fitXY" android:layout_alignParentRight="true" />
</RelativeLayout>
</LinearLayout>
may need to toggle imgbutton layout_width="wrap_content" or if im way off, this is what i found on it.
not sure if you noticed the edit^
haha, thanks for the update, I didn't notice it until now I will try it shortly, and let you know!
EDIT: Nope, it didn't work... Thanks though; any other ideas? All that shows up is a non rotated weather icon, everything else is gone...
Hmm.
So the xml posted was just for the HI screen right?
Or for every ticker screen?
Cause since its fuctions are written already(awesome job) it should only be in the layout scripts.
Ill look it over again.
Sent from my SPH-M580BST using Tapatalk 2
The text posted was the original main layout for the vertical view (standbymode_default_vertical.xml) on the ticker, which will be used solely for standbymode_default_horizontal.xml...
This is what the main standbymode.xml looks like now:
Code:
<?xml version="1.0" encoding="utf-8"?>
<com.android.server.ticker.TickerStandByView android:orientation="vertical" android:focusable="true" android:descendantFocusability="afterDescendants"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:layout_gravity="bottom" android:orientation="horizontal" android:id="@id/LinearLayout01" android:background="@drawable/tt_noti_bg_01" android:layout_width="480.0px" android:layout_height="96.0px">
<include android:id="@id/standbymode_default_vertical" android:layout_width="fill_parent" layout="@layout/standbymode_default_vertical" />
<include android:id="@id/standbymode_default_horizontal" android:visibility="gone" android:layout_width="fill_parent" layout="@layout/standbymode_default_horizontal" />
<include android:id="@id/standbymode_quicklaunch" android:visibility="gone" android:layout_width="fill_parent" layout="@layout/standbymode_quicklaunch" />
<include android:id="@id/standbymode_sleepmode" android:visibility="gone" android:layout_width="fill_parent" layout="@layout/standbymode_sleepmode" />
</LinearLayout>
<ImageView android:id="@id/cacheImageView" android:visibility="invisible" android:layout_width="fill_parent" android:layout_height="fill_parent" />
</com.android.server.ticker.TickerStandByView>
But you know what I just noticed??? The first line of the main standbymode.xml page includes
Code:
android:orientation="vertical"
. I'm going to test something out...
Hey TB did you finish my request or are you still working on it?
Sent from my SCH-I400 using xda app-developers app
trailblazer101 said:
The text posted was the original main layout for the vertical view (standbymode_default_vertical.xml) on the ticker, which will be used solely for standbymode_default_horizontal.xml...
This is what the main standbymode.xml looks like now:
Code:
But you know what I just noticed??? The first line of the main standbymode.xml page includes
Code:
android:orientation="vertical"
. I'm going to test something out...
Click to expand...
Click to collapse
Yes I see it too.. also try reversing the hieght and width
Also isn't vertical=lanscape and horizontal=portrait?
Because when in portrait the lines are horizontal ya know what I mean?
Sent from my SPH-M580BST using Tapatalk 2
To be honest Jaggar345, I kinda sideburner-ed it, since I sorta got sucked up into this rotation project, haha... Is there a time frame thouegh that you would like it done by? Because I could focus my energy onto it again if you wanted it soon!
and yeah Ciscogee, you're right! haha.. Wasn't thinking straight there for a second
off topic, kinda
so this is the only instance of the ticker shown as the 3rd screen,
Code:
#define FULL_SCREEN_WIDTH 479
#define MAIN_SCREEN_HEIGHT 799
#define SOFTKEYS_SCREEN_HEIGHT 96
#define TICKER_SCREEN_HEIGHT 96
#define SOFTKEYS_WIDTH 120
#define MAIN_SCREEN 1
#define SOFTKEYS_SCREEN 2
#define TICKER_SCREEN 3
#define DEFAULT_PRESSURE_UP 0
#define DEFAULT_PRESSURE_DOWN 256
my question is:
what are the fascinates dimensions if a simple,
REMOVE ticker from this module AND port dimensions
OR
just REMOVE ticker from module? (cause if removed, do i extend the max hieght and width? or does it know what to do[LOL]?)
what are your thoughts since you put so much effort into cracking the ticker? there is also an api viewer that you can see the ticker smali, cause im just thinking that since we dont have ticker sources then it would be most difficult to write the ticker into each platform if i can work out errors in 2.6.32.9 kernel we could up date the linux kernel to boot GB+.
trailblazer101 said:
To be honest Jaggar345, I kinda sideburner-ed it, since I sorta got sucked up into this rotation project, haha... Is there a time frame thouegh that you would like it done by? Because I could focus my energy onto it again if you wanted it soon!
and yeah Ciscogee, you're right! haha.. Wasn't thinking straight there for a second
Click to expand...
Click to collapse
Not really a time frame but im kinda looking for something new on my phone and what I requested is what I would like, You don't need to rush with it but try not to take ages to do it.
Thanks

problem using tabs

Ok so I made my first tab class. Has 3 tabs. Everything works fine but was wondering how make put a class into one of the tabs.
This is my class that contains the tabs:
Code:
public class TABS extends Activity {
[user=439709]@override[/user]
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.tablayout);
TabHost th = (TabHost) findViewById(R.id.tabhost);
th.setup();
TabSpec specs = th.newTabSpec("tag1");
specs.setContent(R.id.tab1);
specs.setIndicator("Practise");
th.addTab(specs);
specs = th.newTabSpec("tag2");
specs.setContent(R.id.tab2);
specs.setIndicator("Main Activity");
th.addTab(specs);
specs= th.newTabSpec("tag3");
specs.setContent(R.id.tab3);
specs.setIndicator("Pracfg4tise");
th.addTab(specs);
}
}
XML Layout for the tabbed class:
Code:
<?xml version="1.0" encoding="utf-8"?>
<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:orientation="vertical"
tools:context=".TABS" >
<TabHost
android:id="@+id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/tab1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tab 1 Button" />
</LinearLayout>
<LinearLayout
android:id="@+id/tab2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tab 2 button" />
</LinearLayout>
<LinearLayout
android:id="@+id/tab3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tab 3 Text View" />
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
</LinearLayout>
So I have another class called mainactivity. nothing special on it, just a few textviews and buttons and what not. So how do I set up the mainactivity into the tabs so that if i press the tab that says 'Main Activity', it will take me to the main activity class.
When setting the "setIndicator" property is where I set my class back when I used TabHost's.
Code:
fourthTabSpec.setIndicator("BlackList", res.getDrawable(R.drawable.blacklist_32)).setContent(new Intent(this,BlackList.class));
There is a different way to do this now using fragments though
Hi,
in my application i used tabs too, the main class that contains tabs usually extends TabsActivity
Then, to use another class as content of a tab just use intents, here a sample:
Intent lendsActivityIntent = new Intent(this,LendsActivity.class);
Intent objectsActivityIntent = new Intent(this,ObjectsActivity.class);
firstTabSpec.setIndicator(getString(R.string.lends_tab), getResources().getDrawable(R.drawable.ic_lends)).setContent(lendsActivityIntent);
secondTabSpec.setIndicator(getString(R.string.objects_tab), getResources().getDrawable(R.drawable.ic_catalogue)).setContent(objectsActivityIntent);
calavera69 said:
Hi,
in my application i used tabs too, the main class that contains tabs usually extends TabsActivity
Then, to use another class as content of a tab just use intents, here a sample:
Intent lendsActivityIntent = new Intent(this,LendsActivity.class);
Intent objectsActivityIntent = new Intent(this,ObjectsActivity.class);
firstTabSpec.setIndicator(getString(R.string.lends_tab), getResources().getDrawable(R.drawable.ic_lends)).setContent(lendsActivityIntent);
secondTabSpec.setIndicator(getString(R.string.objects_tab), getResources().getDrawable(R.drawable.ic_catalogue)).setContent(objectsActivityIntent);
Click to expand...
Click to collapse
I did forget to mention it needs to extend TabActivity
The recommended way is to do it using tabs in the ActionBar now.
Google just released its new support-v7 library which brings the ActionBar to apps on Android 2.1 and above.
So there is really no excuse not to use it anymore.

[Q] can't add linear layouts to app

I am having to update an android app at work, I am new at this, I have to add a page, their existing pages have multiple linear layouts inside a relative layout. when I try to do it, it only allows me to put in 1 linear layout, and I can only put other item/layouts inside of that, I know it can be done, do I have to do it all with code, that seems unnecessarily complicated.
Can you post an example of the xml? Keep in mind that with relative layouts you must define positioning or everything will just overlay everything else, so you may actually be adding all the linearlayouts but you can't see them because they're overlapping each other.
Please post your code and layout to help others know your problem better.
Please make sure you add child to the right parent.
Dear,
This is example of multiple linear layouts inside a relative layout.:
Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_root"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<EditText
android:id="@+id/postTextTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/shareLILayout"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:ems="10"
android:gravity="top|left|start"
android:inputType="textMultiLine" >
<requestFocus />
</EditText>
<LinearLayout
android:id="@+id/shareLILayout"
android:layout_alignParentBottom="true"
android:background="#999999"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:orientation="horizontal" >
<ImageButton
android:contentDescription="@string/li_btn_desc"
android:id="@+id/postToLIButton"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
android:background="@android:color/transparent"
android:src="@drawable/linkedin_switch_off" />
<TextView
android:id="@+id/postToLITextView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/share_on_linkedin"
android:layout_gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/shareLILayout"
android:layout_alignParentBottom="true"
android:background="#999999"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:orientation="horizontal" >
<ImageButton
android:contentDescription="@string/li_btn_desc"
android:id="@+id/postToLIButton"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
android:background="@android:color/transparent"
android:src="@drawable/linkedin_switch_off" />
<TextView
android:id="@+id/postToLITextView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/share_on_linkedin"
android:layout_gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="14sp" />
</LinearLayout>
</RelativeLayout>
try it, and inform me if you have any QA?

Categories

Resources