Example usage for android.widget LinearLayout setBackgroundColor

List of usage examples for android.widget LinearLayout setBackgroundColor

Introduction

In this page you can find the example usage for android.widget LinearLayout setBackgroundColor.

Prototype

@RemotableViewMethod
public void setBackgroundColor(@ColorInt int color) 

Source Link

Document

Sets the background color for this view.

Usage

From source file:com.mk4droid.IMC_Activities.FActivity_TabHost.java

private LinearLayout make_Active_Tab(String text, Drawable dr) {

    LinearLayout ll = new LinearLayout(this);
    ll.setPadding(0, 0, 2, 1);//w w  w  .  j  ava2s  . c  om
    ll.setBackgroundColor(Color.GRAY);

    ll.setTag("ll");
    ll.setOrientation(LinearLayout.VERTICAL);
    ll.setLayoutParams(
            new LinearLayout.LayoutParams(0, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, 1));

    //------ Text 
    TextView tv = new TextView(this);
    tv.setBackgroundColor(Color.TRANSPARENT);
    tv.setTag("tv");
    ll.addView(tv);

    // ------ hbar
    View hbar = new View(this);
    hbar.setTag("hbar");
    hbar.setLayoutParams(
            new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.FILL_PARENT, 10));

    ll.addView(hbar);

    ////////////////////////////////////////
    return ActivateColorize(ll, text, dr);
}

From source file:dcheungaa.procal.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    mainActivities.add(this);
    try {/*from w  w w . j  a v  a2s. com*/
        fx50Parser = new Fx50ParserCallable();
    } catch (Exception e) {
        System.out.println("Fx50 Parser failed to initiate: " + e.getMessage());
    }
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    context = this;
    InputHandler.setContext(this);

    views.put("drawer", (DrawerLayout) findViewById(R.id.drawer_layout));
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, ((DrawerLayout) views.get("drawer")),
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    ((DrawerLayout) views.get("drawer")).setDrawerListener(toggle);
    toggle.syncState();

    //
    //DrawerLayout.LayoutParams lp =(android.support.v4.widget.DrawerLayout.LayoutParams) drawer.getLayoutParams();
    //lp.setMargins(0,200,0,200);
    //drawer.setLayoutParams(lp);

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    views.put("resultDisplay", findViewById(R.id.resultDisplay));

    //Set font
    TextView inquiryDisplay = (TextView) findViewById(R.id.inquiryDisplay);
    TextView matrixDisplay = (TextView) findViewById(R.id.matrixDisplay);
    views.put("matrixDisplay", matrixDisplay);
    views.put("inquiryDisplay", inquiryDisplay);
    final Typeface FONT_FX50 = Typeface.createFromAsset(getAssets(), "fonts/Fx50.otf");
    matrixDisplay.setTypeface(FONT_FX50);
    TextView cursor = (TextView) findViewById(R.id.tv_cursor);
    views.put("cursor", (TextView) findViewById(R.id.tv_cursor));
    cursor.setTypeface(FONT_FX50);

    //keypad gen
    final InputStream inSKey = getResources().openRawResource(R.raw.keypad);
    Display display = getWindowManager().getDefaultDisplay();
    RelativeLayout cm = (RelativeLayout) findViewById(R.id.content_main);
    LinearLayout lls = (LinearLayout) findViewById(R.id.llScreen);
    llKeyPad = (LinearLayout) findViewById(R.id.llKeyPad);
    Resources resources = getResources();
    keyPad = new KeyPad_init(this, resources, inSKey, display, cm, lls, llKeyPad);
    call_load = true;

    horizontalScrollView = (HorizontalScrollView) findViewById(R.id.llHoriScrollView);

    matrixDisplay.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {

            System.out.print("Pressed Boss\n");
            if (event.getAction() == MotionEvent.ACTION_UP) {
                if (!CursorHandler.cursorVisible && DisplayModeHandler.displayMode) {
                    CursorHandler.cursorVisible = true;
                    CursorHandler.blinkCursor();
                    DisplayModeHandler.displayMode = false;
                    InputHandler.updateMatrixDisplay();
                }
                if (!InputHandler.error)
                    CursorHandler.locateCursorPos((int) event.getX());
                InputHandler.error = false;
            }
            return true;

        }
    });

    CursorHandler.blinkCursor();
    if (ContextCompat.checkSelfPermission(this,
            Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
        if (!ActivityCompat.shouldShowRequestPermissionRationale(this,
                Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
            System.out.println("Requesting writing permission");
            ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE },
                    1234);
        }
    }
    if (ContextCompat.checkSelfPermission(this,
            Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
        if (!ActivityCompat.shouldShowRequestPermissionRationale(this,
                Manifest.permission.READ_EXTERNAL_STORAGE)) {
            System.out.println("Requesting reading permission");
            ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE },
                    1235);
        }
    }

    Point size = new Point();
    display.getSize(size);
    screenWidth = size.x;
    screenHeight = size.y;

    //hide VAR keypad
    svVar = (ScrollView) findViewById(R.id.svVar);
    svVar.setVisibility(View.INVISIBLE);
    svVar.setPadding(0, 0, 0, 0);
    svVar.setBackgroundResource(R.drawable.popup_container);
    svVar.setElevation(16f);
    LinearLayout llVar = (LinearLayout) findViewById(R.id.llVarPad);
    llVar.setElevation(32f);
    llVar.setBackgroundColor(context.getResources().getColor(R.color.colorPrimaryDarker));
    varPad = new KeyPad_init(this, resources, display, llVar);

    final InputStream inSCmd = getResources().openRawResource(R.raw.programming_keys);
    svCmd = (ScrollView) findViewById(R.id.svCmd);
    svCmd.setVisibility(View.INVISIBLE);
    svCmd.setPadding(0, 0, 0, 0);
    svCmd.setBackgroundResource(R.drawable.popup_container);
    svCmd.setElevation(16f);
    LinearLayout llCmd = (LinearLayout) findViewById(R.id.llCmdPad);
    llCmd.setElevation(32f);
    llCmd.setBackgroundColor(context.getResources().getColor(R.color.colorAccentDarker));
    cmdPad = new KeyPad_init(this, resources, inSCmd, display, llCmd, "", "COMMAND");

    final InputStream inSConst = getResources().openRawResource(R.raw.constant_keypad);
    svConst = (ScrollView) findViewById(R.id.svConst);
    svConst.setVisibility(View.INVISIBLE);
    svConst.setPadding(0, 0, 0, 0);
    svConst.setBackgroundResource(R.drawable.popup_container);
    svConst.setElevation(16f);
    LinearLayout llConst = (LinearLayout) findViewById(R.id.llConstPad);
    llConst.setElevation(32f);
    llConst.setBackgroundColor(context.getResources().getColor(R.color.colorSecondaryDarker));
    constPad = new KeyPad_init(this, resources, inSConst, display, llConst, "&", "CONSTANT");

    // ATTENTION: This was auto-generated to implement the App Indexing API.
    // See https://g.co/AppIndexing/AndroidStudio for more information.
    client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
}

From source file:com.mk4droid.IMC_Activities.FActivity_TabHost.java

private LinearLayout make_Inactive_Tab(String text, Drawable dr) {

    LinearLayout ll = new LinearLayout(this);

    ll.setPadding(0, 0, 2, 1);/*from   ww w  .  j  av a2 s .  co m*/

    ll.setBackgroundColor(Color.GRAY);

    ll.setTag("ll");
    ll.setOrientation(LinearLayout.VERTICAL);
    ll.setLayoutParams(
            new LinearLayout.LayoutParams(0, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, 1));

    //------ Text 
    TextView tv = new TextView(this);
    tv.setBackgroundColor(Color.TRANSPARENT);
    tv.setTag("tv");
    ll.addView(tv);

    // ------ hbar
    View hbar = new View(this);
    hbar.setTag("hbar");
    hbar.setLayoutParams(
            new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.FILL_PARENT, 10));

    ll.addView(hbar);

    /////////////////////////////////////
    return InActivateColorize(ll, text, dr);
}

From source file:pylapp.smoothclicker.android.views.MyAppIntroFragment.java

/**
 *
 * @param inflater -//from   ww  w.j a v a2  s  .c  om
 * @param container -
 * @param savedInstanceState -
 * @return View -
 */
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {

    View v = inflater.inflate(com.github.paolorotolo.appintro.R.layout.fragment_intro, container, false);
    TextView t = (TextView) v.findViewById(com.github.paolorotolo.appintro.R.id.title);
    t.setTextSize(getResources().getDimension(R.dimen.introscreens_title_text_size));
    TextView d = (TextView) v.findViewById(com.github.paolorotolo.appintro.R.id.description);
    d.setTextSize(getResources().getDimension(R.dimen.introscreens_desc_text_size));
    ImageView i = (ImageView) v.findViewById(com.github.paolorotolo.appintro.R.id.image);
    LinearLayout m = (LinearLayout) v.findViewById(com.github.paolorotolo.appintro.R.id.main);

    t.setText(mTitle);
    if (mTitleColor != 0)
        t.setTextColor(mTitleColor);

    d.setText(mDescription);
    if (mDescriptionColor != 0)
        d.setTextColor(mDescriptionColor);

    i.setImageDrawable(ContextCompat.getDrawable(getActivity(), mDrawable));
    m.setBackgroundColor(mBackgroundColor);

    return v;

}

From source file:de.enlightened.peris.SocialFragment.java

@Override
public void onStart() {

    super.onStart();

    this.chatForum = this.application.getSession().getServer().chatForum;
    this.chatThread = this.application.getSession().getServer().chatThread;
    this.socialList = (ListView) getActivity().findViewById(R.id.social_list_view);
    this.socialList.setDivider(null);
    this.updateStatusButton = (Button) getActivity().findViewById(R.id.social_submit_status);
    this.newStatus = (EditText) getActivity().findViewById(R.id.social_status);

    if (this.application.getSession().getServer().serverColor.contains("#")) {
        this.updateStatusButton
                .setTextColor(Color.parseColor(this.application.getSession().getServer().serverColor));
    }/*from w w  w .  j  a va 2  s .com*/

    if (this.application.getSession().getServer().serverTextColor.contains("#")) {
        this.newStatus
                .setTextColor(Color.parseColor(this.application.getSession().getServer().serverTextColor));

        if (this.application.getSession().getServer().serverColor
                .contentEquals(this.application.getSession().getServer().serverBoxColor)) {
            this.updateStatusButton
                    .setTextColor(Color.parseColor(this.application.getSession().getServer().serverTextColor));
        }
    }

    final Bundle bundle = getArguments();
    final String sharedText = bundle.getString("shared_text");
    if (sharedText.length() > 1) {
        this.newStatus.setText(sharedText);
    }
    this.newStatus.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        @SuppressWarnings("checkstyle:requirethis")
        public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                submitPost();
                return true;
            }
            return false;
        }

    });

    this.updateStatusButton.setOnClickListener(this.clickListener);

    String boxColor = getString(R.string.default_element_background);

    if (this.application.getSession().getServer().serverBoxColor != null) {
        boxColor = this.application.getSession().getServer().serverBoxColor;
    }

    if (boxColor.contains("#")) {
        final LinearLayout chatInputArea = (LinearLayout) getActivity().findViewById(R.id.chat_input_area);
        chatInputArea.setBackgroundColor(Color.parseColor(boxColor));
    }

}

From source file:semanticweb.hws14.movapp.activities.MovieDetail.java

private void colorIt(TextView tv) {
    LinearLayout p = (LinearLayout) tv.getParent();
    if (rowCount % 2 == 0) {
        p.setBackgroundColor(Color.rgb(206, 238, 237));
    } else {/* w w  w  .  j a v  a2 s .co  m*/
        p.setBackgroundColor(Color.rgb(236, 248, 248));
    }
    rowCount++;
}

From source file:org.apache.cordova.SplashScreenInternal.java

/**
 * Shows the splash screen over the full Activity
 *///from  ww  w  . j a  v  a 2  s .  co m
@SuppressWarnings("deprecation")
private void showSplashScreen(final boolean hideAfterDelay) {
    final int splashscreenTime = preferences.getInteger("SplashScreenDelay", 3000);
    final int drawableId = preferences.getInteger("SplashDrawableId", 0);

    // If the splash dialog is showing don't try to show it again
    if (this.splashDialog != null && splashDialog.isShowing()) {
        return;
    }
    if (drawableId == 0 || (splashscreenTime <= 0 && hideAfterDelay)) {
        return;
    }

    cordova.getActivity().runOnUiThread(new Runnable() {
        public void run() {
            // Get reference to display
            Display display = cordova.getActivity().getWindowManager().getDefaultDisplay();
            Context context = webView.getContext();

            // Create the layout for the dialog
            LinearLayout root = new LinearLayout(context);
            root.setMinimumHeight(display.getHeight());
            root.setMinimumWidth(display.getWidth());
            root.setOrientation(LinearLayout.VERTICAL);

            // TODO: Use the background color of the webview's parent instead of using the
            // preference.
            root.setBackgroundColor(preferences.getInteger("backgroundColor", Color.BLACK));
            root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));
            root.setBackgroundResource(drawableId);

            // Create and show the dialog
            splashDialog = new Dialog(context, android.R.style.Theme_Translucent_NoTitleBar);
            // check to see if the splash screen should be full screen
            if ((cordova.getActivity().getWindow().getAttributes().flags
                    & WindowManager.LayoutParams.FLAG_FULLSCREEN) == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
                splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                        WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
            splashDialog.setContentView(root);
            splashDialog.setCancelable(false);
            splashDialog.show();

            // Set Runnable to remove splash screen just in case
            if (hideAfterDelay) {
                final Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    public void run() {
                        removeSplashScreen();
                    }
                }, splashscreenTime);
            }
        }
    });
}

From source file:com.common.widget.pageindicator.C_TabPageIndicator.java

@SuppressLint("NewApi")
// private void addTab(int index, CharSequence text, int iconResId) {
// final TabView tabView = new TabView(getContext());
// tabView.mIndex = index;
// tabView.setFocusable(true);
// tabView.setOnClickListener(mTabClickListener);
// tabView.setText(text);
// if (iconResId != 0) {
// // tabView.setCompoundDrawablePadding(
// // (int) getResources().getDimension(R.dimen.margin1));
// tabView.setCompoundDrawablesWithIntrinsicBounds(0, iconResId, 0, 0);
// // setTabIcon(tabView, iconResId);
// }/*from  w  w w .j a v a2s.  c om*/
// if (deviceWeight) {
// mTabLayout.addView(tabView, new LinearLayout.LayoutParams(0,
// MATCH_PARENT, 1));
// } else {
// LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
// WRAP_CONTENT, MATCH_PARENT);
// lp.leftMargin = 10;
// lp.rightMargin = 10;
// mTabLayout.addView(tabView, lp);
// }
// }
private void addTab(int index, CharSequence text, int iconResId) {
    if (deviceWeight) { // tab  ? Layout
        LinearLayout layout = new LinearLayout(getContext());
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(WRAP_CONTENT, MATCH_PARENT, 1);
        //???GG
        layout.setBackgroundColor(C_ResUtil.getSrcColor(R.color.full_transparent));
        layout.setGravity(Gravity.CENTER);
        // TextView
        final TabView tabView = new TabView(getContext());
        tabView.mIndex = index;
        // ?layoutLayout???
        tabView.setFocusable(false);
        tabView.setClickable(false);
        tabView.setOnClickListener(mTabClickListener);
        tabView.setText(text);
        if (iconResId != 0) {
            //             tabView.setCompoundDrawablesWithIntrinsicBounds(0, iconResId,
            //             0, 0);
            //                tabView.setPaddingRelative(10, 10, 10, 10);
            //                tabView.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0,
            //                        iconResId, 0);
            tabView.setBackgroundResource(iconResId);
        }
        tabView.setPadding(C_ResUtil.getDimens(R.dimen._10dp), 0, C_ResUtil.getDimens(R.dimen._10dp), 0);
        LinearLayout.LayoutParams tvlp = new LinearLayout.LayoutParams(WRAP_CONTENT,
                C_ResUtil.getDimens(R.dimen._22dp));
        tvlp.rightMargin = C_ResUtil.getDimens(R.dimen._2dp);
        tvlp.leftMargin = C_ResUtil.getDimens(R.dimen._2dp);
        layout.addView(tabView, tvlp);
        layout.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                tabView.performClick();
            }
        });
        // TextView
        mTabLayout.addView(layout, lp);
    } else {
        final TabView tabView = new TabView(getContext());
        tabView.mIndex = index;
        tabView.setFocusable(true);
        tabView.setOnClickListener(mTabClickListener);
        tabView.setText(text);
        if (iconResId != 0) {
            // tabView.setCompoundDrawablePadding(
            // (int) getResources().getDimension(R.dimen.margin1));
            // tabView.setCompoundDrawablesWithIntrinsicBounds(0, iconResId,
            // 0, 0);
            tabView.setPaddingRelative(10, 10, 10, 10);
            tabView.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, iconResId, 0);
            // setTabIcon(tabView, iconResId);
        }
        tabView.setPadding(C_ResUtil.getDimens(R.dimen._10dp), 0, C_ResUtil.getDimens(R.dimen._10dp), 0);
        // if (deviceWeight) {
        // mTabLayout.addView(tabView, new LinearLayout.LayoutParams(0,
        // MATCH_PARENT, 1));
        // } else {
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(WRAP_CONTENT,
                C_ResUtil.getDimens(R.dimen._22dp));
        lp.leftMargin = C_ResUtil.getDimens(R.dimen._2dp);
        lp.rightMargin = C_ResUtil.getDimens(R.dimen._2dp);
        //         mTabLayout.addView(tabView, lp);
        // }
    }
}

From source file:com.example.appf.CS3570.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();//from   www .  j av a 2s .com
    Bundle extras = intent.getExtras();
    cam = false;

    // Just in case we are coming from the ServerActivity
    if (extras != null) {
        if (extras.containsKey("server_name"))
            SERVER_IP = extras.getString("server_name");
        if (extras.containsKey("server_port"))
            SERVERPORT = Integer.parseInt(extras.getString("server_port"));
    }
    filter = new IMUfilter(.1f, 5);
    filter.reset();

    // Set up reset button
    Button b = new Button(this);
    b.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            filter.reset();
        }
    });
    b.setText("Reset");

    // Set up camera mode. Are we going to use this?
    Button c = new Button(this);
    c.setText("Camera Mode");
    c.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            filter.reset();
            mGLView.mRenderer.mCamera = new Camera();
            cam = !cam;
        }
    });
    LinearLayout ll = new LinearLayout(this);
    ll.setOrientation(LinearLayout.VERTICAL);
    ll.setBackgroundColor(Color.parseColor("#21C9FF"));
    ll.addView(b);
    ll.addView(c);
    // Create a GLSurfaceView instance and set it
    // as the ContentView for this Activity
    mGLView = new MyGLSurfaceView(this, this);
    ll.addView(mGLView);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
    gyroscope = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);
    accelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    magnetometer = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
    setContentView(ll);
    new Thread(new SocketThread()).start();
}

From source file:org.zywx.wbpalmstar.plugin.uexPopoverMenu.EUExPopoverMenu.java

private void showPopoverMenu(double x, double y, int direction, String bgColorStr, String dividerColor,
        String textColor, int textSize, JSONArray data) {
    LinearLayout rootView = (LinearLayout) LayoutInflater.from(mContext)
            .inflate(finder.getLayoutId("plugin_uex_popovermenu"), null);

    final PopupWindow popupWindow = new PopupWindow(rootView, LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT, true);

    popupWindow.setContentView(rootView);
    ///* www  . j  a  va  2s  . c o m*/
    rootView.setBackgroundColor(Color.parseColor(bgColorStr));
    popupWindow.setContentView(rootView);
    //popupWindow?
    popupWindow.setBackgroundDrawable(new BitmapDrawable());
    popupWindow.setOutsideTouchable(true);

    int length = data.length();
    List<ItemData> itemDataList = new ArrayList<ItemData>();
    try {
        for (int i = 0; i < length; i++) {
            ItemData item = new ItemData();
            String icon = data.getJSONObject(i).optString("icon", "");
            if (!hasIcon && !TextUtils.isEmpty(icon)) {
                hasIcon = true;
            }
            if (hasIcon) {
                item.setIcon(data.getJSONObject(i).getString("icon"));
            }
            item.setText(data.getJSONObject(i).getString("text"));
            itemDataList.add(item);
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }

    for (int i = 0; i < length; i++) {
        LinearLayout linearLayout = new LinearLayout(mContext);
        linearLayout.setOrientation(LinearLayout.HORIZONTAL);
        linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));

        if (hasIcon) {
            ImageView imageView = new ImageView(mContext);
            imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT));
            String imagePath = itemDataList.get(i).getIcon();
            imageView.setImageBitmap(getBitmapFromPath(imagePath));
            imageView.setPadding(DensityUtil.dip2px(mContext, 5), 0, 0, 0);
            linearLayout.addView(imageView);
        }
        TextView tvText = new TextView(mContext);
        LinearLayout.LayoutParams tvLayoutParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        tvLayoutParams.gravity = Gravity.CENTER_VERTICAL;
        tvText.setLayoutParams(tvLayoutParams);

        tvText.setPadding(DensityUtil.dip2px(mContext, 5), 0, DensityUtil.dip2px(mContext, 8), 0);
        tvText.setText(itemDataList.get(i).getText());
        tvText.setTextColor(Color.parseColor(textColor));
        tvText.setTextSize(textSize);
        linearLayout.addView(tvText);
        linearLayout.setTag(i);
        linearLayout.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                callBackPluginJs(CALLBACK_ITEM_SELECTED, String.valueOf(v.getTag()));
                if (popupWindow != null && popupWindow.isShowing()) {
                    popupWindow.dismiss();
                }
            }
        });
        rootView.addView(linearLayout);

        //
        View dividerLine = new View(mContext);
        dividerLine.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                DensityUtil.dip2px(mContext, 1)));
        dividerLine.setBackgroundColor(Color.parseColor(dividerColor));
        rootView.addView(dividerLine);
    }
    int gravityParam;
    switch (direction) {
    case 0:
        gravityParam = Gravity.LEFT | Gravity.TOP;
        break;
    case 1:
        gravityParam = Gravity.RIGHT | Gravity.TOP;
        break;
    case 2:
        gravityParam = Gravity.LEFT | Gravity.BOTTOM;
        break;
    case 3:
        gravityParam = Gravity.RIGHT | Gravity.BOTTOM;
        break;
    default:
        gravityParam = Gravity.LEFT | Gravity.TOP;
        break;
    }
    popupWindow.showAtLocation(mBrwView.getRootView(), gravityParam, (int) x, (int) y);
}