Reputation: 13
I have a DrawingLayout on my android app's landing page. I want to make it visible throughout the application so that I can use that as navigation control for my app. Is it possible? If Yes, how can I achieve that?
Thanks a lot in advance.
Upvotes: 1
Views: 102
Reputation: 3001
create a class which return a Linear layout containing all your navigation controls which you want on your application screens and add that to your activity by method addView(lin_layout);
look at this
public class yourClass{
Context context;
public LinearLayout createNavBar(int tooBarHeight,String mTitle, Context mContext)
{
LinearLayout topBar = new LinearLayout(mContext);
topBar.setGravity(Gravity.TOP);
topBar.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,tooBarHeight));
topBar.setBackgroundDrawable(d);
TextView text = new TextView(mContext);
text.setLayoutParams(new LayoutParams(width - 2*tooBarHeight,tooBarHeight));
text.setGravity(Gravity.CENTER_VERTICAL);
text.setText(mTitle);
text.setTextColor(Color.WHITE);
text.setPadding(15, 10, 0, 0);
text.setTextSize(18);
topBar.addView(text);
Button home = new Button(mContext);
home.setLayoutParams(new LayoutParams(tooBarHeight,LayoutParams.MATCH_PARENT));
//home.setPadding(15, 15, 15, 15);
home.setGravity(Gravity.RIGHT & Gravity.CENTER_VERTICAL);
topBar.addView(home);
home.setOnClickListener(new View.OnClickListener() {
});
Button order = new Button(mContext);
order.setLayoutParams(new LayoutParams(tooBarHeight,LayoutParams.MATCH_PARENT));
order.setGravity(Gravity.RIGHT & Gravity.CENTER_VERTICAL);
//order.setPadding(15, 15, 15, 15);
topBar.addView(order);
order.setOnClickListener(new View.OnClickListener() {
});
return topBar;
}
} you can add this nav bar to your activity by
yourClass toolbar = new yourClass();
LinearLayout topBar = toolbar.createNavBar(72,"your title", mContext);
this.addView(topBar);
Upvotes: 1