Skip to content

Commit

Permalink
Fix toolbar layout
Browse files Browse the repository at this point in the history
  • Loading branch information
kitrio committed Oct 4, 2019
1 parent a8b427a commit f896ce3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;

import android.view.WindowManager;
import android.widget.ProgressBar;
import org.json.JSONObject;
Expand Down Expand Up @@ -135,24 +134,26 @@ protected void onCreate(Bundle savedInstanceState) {
mToolbarView = new ToolbarLayout(this, mTabSessionManager);
mToolbarView.setId(R.id.toolbar_layout);
mToolbarView.setTabListener(this::switchToSessionAtIndex);

mToolbarView.setLayoutParams(new ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_CONSTRAINT,ConstraintLayout.LayoutParams.WRAP_CONTENT));
Toolbar toolbar = findViewById(R.id.toolbar);
toolbar.setLayoutParams(new Constraints.LayoutParams(ConstraintLayout.LayoutParams.WRAP_CONTENT,80));
toolbar.setBackgroundResource(R.drawable.ic_menu);


ConstraintLayout appLayout = findViewById(R.id.main);

ConstraintSet set = new ConstraintSet();
appLayout.addView(mToolbarView,1);
appLayout.addView(mToolbarView);
set.clone(appLayout);
set.connect(R.id.gecko_view,ConstraintSet.TOP, ConstraintSet.PARENT_ID,ConstraintSet.TOP);
set.connect(R.id.gecko_view,ConstraintSet.BOTTOM, R.id.toolbar_layout,ConstraintSet.TOP);

set.connect(R.id.toolbar, ConstraintSet.TOP,R.id.gecko_view,ConstraintSet.BOTTOM);
set.connect(R.id.toolbar, ConstraintSet.LEFT,R.id.toolbar_layout,ConstraintSet.RIGHT);
set.connect(R.id.toolbar, ConstraintSet.RIGHT,R.id.main,ConstraintSet.RIGHT);
set.connect(R.id.toolbar, ConstraintSet.TOP,R.id.gecko_view,ConstraintSet.BOTTOM);
set.connect(R.id.toolbar, ConstraintSet.BOTTOM, R.id.toolbar_layout,ConstraintSet.BOTTOM);

set.connect(R.id.toolbar_layout,ConstraintSet.LEFT,R.id.main,ConstraintSet.LEFT);
set.connect(R.id.toolbar_layout,ConstraintSet.RIGHT,R.id.toolbar,ConstraintSet.LEFT);
set.connect(R.id.toolbar_layout,ConstraintSet.TOP,R.id.gecko_view,ConstraintSet.BOTTOM);
set.connect(R.id.toolbar_layout,ConstraintSet.BOTTOM,R.id.main,ConstraintSet.BOTTOM);
set.applyTo(appLayout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.content.Context;
import android.graphics.Color;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
Expand All @@ -27,31 +26,27 @@ public ToolbarLayout(Context context, TabSessionManager sessionManager) {

private void initView() {

setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1.0f));
setPadding(20,0,20,0);
setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1));
setPadding(40,0,20,0);
setOrientation(LinearLayout.HORIZONTAL);

mLocationView = new LocationView(getContext());
mLocationView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1.0f));//notice
mLocationView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1));
mLocationView.setBackgroundColor(Color.TRANSPARENT);
mLocationView.setPadding(20,0,10,0);
mLocationView.setId(R.id.url_bar);
addView(mLocationView);

mTabsCountButton = getTabsCountButton();
mTabsCountButton.setPadding(0,0,0,0);
addView(mTabsCountButton);

}

private Button getTabsCountButton() {
Button button = new Button(getContext());
button.setLayoutParams(new LayoutParams(100, LayoutParams.WRAP_CONTENT));
button.setPadding(10,10,10,10);
button.setId(R.id.tabs_button);
button.setOnClickListener(this::onTabButtonClicked);
button.setBackgroundResource(R.drawable.tab_number_background);
//button.setBackgroundColor(Color.TRANSPARENT);
return button;
}

Expand Down

0 comments on commit f896ce3

Please sign in to comment.