I use this code for custom dialog title XML-layout
public class UtilityDialog extends Dialog
{
onCreate(Bundle savedInstanceState)
{
....
....
....
getWindow().requestFeature(Window.FEATURE_CUSTOM_TITLE);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.dialog_title);
setContentView(content);
}
}
it works but height of title is too small and it does not contains any UI element of
R.layout.dialog_title
R.layout.dialog_title-->
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="65dip"
android:padding="2dip"
android:background="#android:color/transparent">
<ImageView
android:id="#+id/logoImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="#drawable/logo" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Cellalert" />
</RelativeLayout>
Related
I am trying to implement a panel in a fragment that can expand on button click from the right side of the screen. I can't use the navigation drawer, because I already have navigation drawers from both left and right sides.
The idea is to achieve something like that:
I was almost able to do it with the SlidingDrawer widget (it's deprecated..), the only problem is that I don't know how to make the LinearLayout to appear in the middle and then to shift when the button to expand the SlidingDrawer is clicked.
I have the following code:
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button handle = (Button) findViewById(R.id.handle);
SlidingDrawer drawer = (SlidingDrawer) findViewById(R.id.slidingDrawer);
drawer.setOnDrawerOpenListener(new SlidingDrawer.OnDrawerOpenListener() {
#Override
public void onDrawerOpened() {
}
});
drawer.setOnDrawerCloseListener(new SlidingDrawer.OnDrawerCloseListener() {
#Override
public void onDrawerClosed() {
}
});
}
}
And the XML code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context="com.test.slidingdrawertest.slidingdrawertest.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEST TEST TEST" />
</LinearLayout>
<LinearLayout
android:layout_alignParentEnd="true"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<SlidingDrawer
android:id="#+id/slidingDrawer"
android:layout_width="200dp"
android:layout_height="400dp"
android:layout_marginTop="100dp"
android:layout_gravity="end"
android:content="#+id/content"
android:handle="#+id/handle"
android:orientation="horizontal">
<Button
android:id="#+id/handle"
style="?android:attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Expand" />
<LinearLayout
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEST TEST TEST" />
</LinearLayout>
</SlidingDrawer>
</LinearLayout>
</RelativeLayout>
You can edit your XML like this
?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:padding="10dp"
tools:context="com.test.slidingdrawertest.slidingdrawertest.MainActivity">
<LinearLayout
android:id="#+id/left" // this is your linear layout
android:layout_width="match_parent" // that you want to shift left
android:layout_height="match_parent"
android:layout_toLeftOf="#+id/right" // apply this property due to
android:layout_alignParentLeft="true" //which if the width of sliding menu
android:gravity="center" //increase it will automatically compressed
android:background="#aa00aa"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEST TEST TEST" />
</LinearLayout>
<LinearLayout
android:id="#+id/right"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:background="#0000aa"
android:layout_height="match_parent">
<SlidingDrawer
android:id="#+id/slidingDrawer"
android:layout_width="200dp" // you can check by increasing or decreasing the with of this slidingdrawer
android:layout_height="400dp"
android:layout_marginTop="100dp"
android:layout_gravity="end"
android:content="#+id/content"
android:handle="#+id/handle"
android:orientation="horizontal">
<Button
android:id="#+id/handle"
style="?android:attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Expand" />
<LinearLayout
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEST TEST TEST" />
</LinearLayout>
</SlidingDrawer>
</LinearLayout>
</RelativeLayout>
apart from this if set any layout to the right of your linear layout which is initially GONE and as you click on the button its visibility changed to INVISIBLE/VISIBLE so it will shift the linear layout to left. Hope that helps!
If you want a little exemple here is my solution: (I don't know if Avani Nagar's solution works or not):
TextView res;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final TextView img = (TextView)findViewById(R.id.second);
res = (TextView)findViewById(R.id.first);
img.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
img.setX(img.getX() - 5);
changew(img.getX());
}
});
}
private void changew(float w){
res.getLayoutParams().width = (int)(res.getX() +w);
res.requestLayout();
res.invalidate();
}
The xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/black">
<TextView
android:layout_toRightOf="#+id/first"
android:text="bonjourrrrrr"
android:id="#+id/second"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:background="#android:color/holo_red_dark" />
<TextView
android:text="salutttttttt"
android:id="#id/first"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:background="#android:color/holo_green_light" />
</RelativeLayout>
I managed to do it, it actually wasn't so difficult, but it's a little tricky. Here is the solution:
The xml code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:id="#+id/topLayout"
tools:context="com.test.slidingdrawertest.slidingdrawertest.MainActivity">
<LinearLayout
android:id="#+id/mainLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEST" />
</LinearLayout>
<LinearLayout
android:layout_alignParentEnd="true"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<SlidingDrawer
android:id="#+id/slidingDrawer"
android:layout_width="200dp"
android:layout_height="400dp"
android:layout_marginTop="100dp"
android:layout_gravity="end"
android:content="#+id/content"
android:handle="#+id/handle"
android:orientation="horizontal">
<Button
android:id="#+id/handle"
style="?android:attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Expand" />
<LinearLayout
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEST TEST TESTT" />
</LinearLayout>
</SlidingDrawer>
</LinearLayout>
</RelativeLayout>
The code in MainActivity.java:
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button handle = (Button) findViewById(R.id.handle);
SlidingDrawer drawer = (SlidingDrawer) findViewById(R.id.slidingDrawer);
final View k = findViewById(R.id.mainLayout);
drawer.setOnDrawerOpenListener(new SlidingDrawer.OnDrawerOpenListener() {
#Override
public void onDrawerOpened() {
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
k.setLayoutParams(params);
}
});
drawer.setOnDrawerCloseListener(new SlidingDrawer.OnDrawerCloseListener() {
#Override
public void onDrawerClosed() {
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
k.setLayoutParams(params);
}
});
}
}
And the explanation: I had to give main main layout an id (in XML) and then find it in the code behind, then I had to apply new parameters to it when the drawer opens or closes. Basically, we need to find the parent layout and set the parameters to it.
Now the LinearLayout is able to shift it's position on drawer open, and it goes back to it's original position on drawer close. Next step is to make this process with an animation, so it's smooth and doesn't just jump back and forth to the new positions.
I want to create sliding drawer in android which should be placed on top of the activity and should be open from top to bottom like android notification panel. How to achieve this?
The default SlidingDrawer class doesn't allow this. You can use the Panel class from here to get something very similar though OR set the rotation of 180ยบ for the SlidingDrawer, the content and the handle. Note : android:rotation is support on API > Level 11
http://www.ohloh.net/p/android-misc-widgets
https://github.com/IanDarwin/Android-Cookbook-Examples/tree/master/SlidingDrawer-Topdown
Reference
If you want to have sliding drawer from top to bottom then just copy pase this code in your project, it is 100% working code.
main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#d3d3d3"
>
<SlidingDrawer
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/slidingDrawer"
android:layout_width="wrap_content"
android:layout_height="300dp"
android:content="#+id/content"
android:gravity="center_horizontal"
android:handle="#+id/handle"
android:orientation="vertical"
android:rotation="180" >
<LinearLayout
android:id="#+id/handle"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:gravity="right"
android:background="#+drawable/drawer_bk"
>
<ImageView
android:id="#+id/imageView"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="#+drawable/drawer1" />
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="45dp" >
<RelativeLayout
android:id="#+id/rel1"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="10dp"
android:rotation="180" >
<ImageView
android:id="#+id/ImageView04"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:onClick="visit"
android:src="#drawable/visit_icon" />
<ImageView
android:id="#+id/ImageView03"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_alignParentTop="true"
android:layout_marginRight="35dp"
android:layout_toLeftOf="#+id/ImageView04"
android:onClick="contact_us"
android:src="#drawable/contact_icon" />
<ImageView
android:id="#+id/ImageView02"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_alignParentTop="true"
android:layout_marginLeft="35dp"
android:layout_toRightOf="#+id/ImageView04"
android:onClick="logout"
android:src="#drawable/singout_icon" />
</RelativeLayout>
</RelativeLayout>
</SlidingDrawer>
MainActivity.java
public class MainActivity extends Activity
{
/** Duration of wait **/
private final int SPLASH_DISPLAY_LENGTH = 4000;
Button slideButton,b1, b2,b3,b4;
SlidingDrawer slidingDrawer;
#SuppressWarnings("deprecation")
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//slideButton = (Button) findViewById(R.id.slideButton);
slidingDrawer = (SlidingDrawer) findViewById(R.id.slidingDrawer);
slidingDrawer.setOnDrawerOpenListener(new OnDrawerOpenListener() {
#Override
public void onDrawerOpened()
{
// slideButton.setBackgroundResource(R.drawable.down_arrow_icon);
slidingDrawer.setBackgroundResource(R.drawable.hd_img_1);
}
});
slidingDrawer.setOnDrawerCloseListener(new OnDrawerCloseListener()
{
#Override
public void onDrawerClosed()
{
// slideButton.setBackgroundResource(R.drawable.upwar_arrow_icon);
slidingDrawer.setBackgroundColor(Color.TRANSPARENT);
}
});
}
}
I am facing a weird issue with dialog fragment , its not showing the complete proper layout. I have checked on Moto G and Nexus 5 both show same result. Any help would be appreciated.
Graphical layout screen shot is:
Device screen shot is:
Here is the activity code:
public class MainActivity extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
showGridTutorial();
}
public void showGridTutorial() {
DialogFragment fragment = new GridTutorial();
fragment.show(getSupportFragmentManager(), "grid_tutorial");
}
public static class GridTutorial extends DialogFragment {
#Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// TODO Auto-generated method stub
Dialog dialog = new Dialog(getActivity());
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.dialog_layout);
return dialog;
}
}
}
XML layout file:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:background="#eeede9"
>
<View
android:id="#+id/vertical"
android:layout_width="1dp"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true"
android:layout_above="#+id/btnGotIt"
android:background="#e8e7e4"
/>
<View
android:id="#+id/horizontal"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_centerVertical="true"
android:background="#e8e7e4" />
<Button
android:id="#+id/btnGotIt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="48dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="Got it"
android:gravity="center"
android:background="#android:color/black"
android:textColor="#eeede9"
android:textAppearance="?android:attr/textAppearanceLarge"
/>
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#+id/vertical"
android:layout_above="#+id/horizontal"
android:src="#drawable/showease3" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/vertical"
android:layout_above="#+id/horizontal"
android:src="#drawable/showdase" />
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/horizontal"
android:layout_toLeftOf="#+id/vertical"
android:layout_above="#+id/btnGotIt"
android:src="#drawable/showcase" />
<ImageView
android:id="#+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/horizontal"
android:layout_toRightOf="#+id/vertical"
android:layout_above="#+id/btnGotIt"
android:src="#drawable/showdase" />
</RelativeLayout>
Try to change RelativeLayout width and height to wrap_content.
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#eeede9"
Hope this will help you!
You need to choose a minimum width and minimum height for your layout. Something like :
android:minWidth="600dp"
android:minHeight="800dp"
Just try playing with the right values.
I want to create a header which contains an ImageView and three Buttons. I have done some coding but the problem is that when we run our app, the header only displays the image and the Buttons are not showing.
My Activity:
public class Header extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.header);
}
}
My XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="false"
android:scaleType="fitXY"
android:src="#drawable/header" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/mid_belt"
android:orientation="horizontal"
android:weightSum="90" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="10"
android:background="#drawable/selector"
android:onClick="click"
android:text="Latest"
android:textColor="#ffffff"
android:textStyle="bold" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="10"
android:background="#drawable/selector"
android:text="News Room"
android:textColor="#ffffff"
android:textStyle="bold" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="10"
android:background="#drawable/selector"
android:text="Featured"
android:textColor="#ffffff"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
you have solved your problem tried like code in your class :
public class Header extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.header);
setContentView(R.layout.main);
}
}
I have a custom ScrollView that works fine if it is the only thing in the emulator.
For example, this works fine:
public class Timeline2Activity extends Activity {
private TimelineView tlv;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
tlv = new TimelineView(this);
setContentView(tlv);
}
}
But if I first add widgets then it fails to appear. I've searched and experimented for 2 days and nothing works.
Here is the class declaration of the custom ScrollView:
public class TimelineView extends ScrollView implements OnTouchListener {
And here are the constructors:
public TimelineView(Context context) {
super(context);
this.setOnTouchListener(this);
setVisibility(VISIBLE);
}
//the following constructor is needed to inflate the view from XML
public TimelineView(Context context, AttributeSet ats) {
super(context,ats);
this.setOnTouchListener(this);
setVisibility(VISIBLE);
}
Here is the main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/container"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<Button
android:id="#+id/zoomall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Zoom All" />
<Button
android:id="#+id/zoomout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-" />
<Button
android:id="#+id/zoomin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+" />
<Spinner
android:id="#+id/category_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:prompt="#string/category_prompt"
/>
</LinearLayout>
<com.projects.timeline2.TimelineView
android:id="#+id/timeline_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
And here is the main program:
public class Timeline2Activity extends Activity {
private TimelineView tlv;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//tlv = new TimelineView(this);
//setContentView(tlv);
setContentView(R.layout.main);
Spinner spinnerCategory = (Spinner) findViewById(R.id.category_spinner);
ArrayAdapter<CharSequence> adapterCategory = ArrayAdapter.createFromResource(
this, R.array.categories, android.R.layout.simple_spinner_item);
adapterCategory.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerCategory.setAdapter(adapterCategory);
spinnerCategory.setOnItemSelectedListener(new MyOnItemSelectedListener());
//TimelineView tlv = (TimelineView) findViewById(R.id.timeline_view);
//ViewGroup container = (ViewGroup) findViewById(R.id.container);
//container.addView(tlv);
}
public class MyOnItemSelectedListener implements OnItemSelectedListener {
public void onItemSelected(AdapterView<?> parent,
View view, int pos, long id) {
Toast.makeText(parent.getContext(), "The selection is " +
parent.getItemAtPosition(pos).toString(), Toast.LENGTH_LONG).show();
}
public void onNothingSelected(AdapterView parent) {
// Do nothing.
}
}
}
The lines commented out are stuff I've tried but didn't work either.
This code correctly puts 3 buttons and a spinner in a horizontal row across the top. But TimelineView fails to appear below them. I know that TimelineView is running because I can see debugging output in the LogCat that I put in.
I'm at my wits end and hope someone can shed some light. This seems like a common fundamental need and sure deserves a google tutorial.
You are using LinearLayout and you have used android:layout_height="fill_parent" to the first element so the first element will fill the whole screen height and there will be no space for the second element (com.projects.timeline2.TimelineView) thats why you are unable to see second element.
Use Relative Layout instead. and mention android:layout_alignParentBottom="true" for second element so that it will always stay to the buttom of the screen and align the first element to the above of second by putting android:layout_above to first element
Your XML will be
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/container"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.projects.timeline2.TimelineView
android:id="#+id/timeline_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:layout_above="#+id/timeline_view">
<Button
android:id="#+id/zoomall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Zoom All" />
<Button
android:id="#+id/zoomout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-" />
<Button
android:id="#+id/zoomin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+" />
<Spinner
android:id="#+id/category_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:prompt="category_prompt"
/>
</LinearLayout>
</RelativeLayout>
I think you should change TimeLine's layout height to fill_parent in xml, or add some content to it.
I finally got it. Here is the main.xml that worked.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/container"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/buttons"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentTop="true"
>
<Button
android:id="#+id/zoomall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Zoom All" />
<Button
android:id="#+id/zoomout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-" />
<Button
android:id="#+id/zoomin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+" />
<Spinner
android:id="#+id/category_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<com.projects.timeline2.TimelineView
android:id="#+id/timeline_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_below="#id/buttons"
/>
</RelativeLayout>
Thanks everyone for getting me going in the right direction!