Java Code Examples for android.widget.LinearLayout#setGravity()

The following examples show how to use android.widget.LinearLayout#setGravity() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SwipeMenuView.java    From Android-PullToRefresh-SwipeMenuListView-Sample with MIT License 6 votes vote down vote up
private void addItem(SwipeMenuItem item, int id) {
    LayoutParams params = new LayoutParams(item.getWidth(), LayoutParams.MATCH_PARENT);
    LinearLayout parent = new LinearLayout(getContext());
    parent.setId(id);
    parent.setGravity(Gravity.CENTER);
    parent.setOrientation(LinearLayout.VERTICAL);
    parent.setLayoutParams(params);
    parent.setBackgroundDrawable(item.getBackground());
    parent.setOnClickListener(this);
    addView(parent);

    if (item.getIcon() != null) {
        parent.addView(createIcon(item));
    }
    if (!TextUtils.isEmpty(item.getTitle())) {
        parent.addView(createTitle(item));
    }

}
 
Example 2
Source File: MultiplePicker.java    From AndroidPicker with MIT License 6 votes vote down vote up
@NonNull
@Override
protected ScrollView makeCenterView() {
    ScrollView scrollView = new ScrollView(activity);
    layout = new LinearLayout(activity);
    layout.setOrientation(LinearLayout.VERTICAL);
    for (String item : items) {
        LinearLayout line = new LinearLayout(activity);
        line.setOrientation(LinearLayout.HORIZONTAL);
        line.setGravity(Gravity.CENTER);
        TextView textView = new TextView(activity);
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, WRAP_CONTENT, 1.0f);
        lp.gravity = Gravity.CENTER;
        textView.setLayoutParams(lp);
        textView.setText(item);
        textView.setGravity(Gravity.CENTER);
        line.addView(textView);
        CheckBox checkBox = new CheckBox(activity);
        checkBox.setLayoutParams(new LinearLayout.LayoutParams(0, WRAP_CONTENT, 0.4f));
        line.addView(checkBox);
        layout.addView(line);
    }
    scrollView.addView(layout);
    return scrollView;
}
 
Example 3
Source File: SDMenuItemView.java    From SlideAndDragListView with Apache License 2.0 6 votes vote down vote up
@Override
protected void build() {
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(mMenuItem.width, ViewGroup.LayoutParams.MATCH_PARENT);
    layoutParams.gravity = Gravity.CENTER;
    setLayoutParams(layoutParams);
    addView(createBG());

    if (!TextUtils.isEmpty(mMenuItem.text) && mMenuItem.icon != null) {
        mImageView = createImageView();
        mTextView = createTextView();
        LinearLayout linearLayout = new LinearLayout(getContext());
        linearLayout.setOrientation(LinearLayout.VERTICAL);
        linearLayout.addView(mImageView);
        linearLayout.addView(mTextView);
        linearLayout.setGravity(Gravity.CENTER);
        addView(linearLayout);
    } else if (mMenuItem.icon != null) {
        mImageView = createImageView();
        addView(mImageView);
    } else if (!TextUtils.isEmpty(mMenuItem.text)) {
        mTextView = createTextView();
        addView(mTextView);
    } else {
        addView(createEmptyView());
    }
}
 
Example 4
Source File: ListFragment.java    From letv with Apache License 2.0 6 votes vote down vote up
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Context context = getActivity();
    FrameLayout root = new FrameLayout(context);
    LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(1);
    pframe.setVisibility(8);
    pframe.setGravity(17);
    pframe.addView(new ProgressBar(context, null, 16842874), new LayoutParams(-2, -2));
    root.addView(pframe, new LayoutParams(-1, -1));
    FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);
    TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(17);
    lframe.addView(tv, new LayoutParams(-1, -1));
    ListView lv = new ListView(getActivity());
    lv.setId(16908298);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new LayoutParams(-1, -1));
    root.addView(lframe, new LayoutParams(-1, -1));
    root.setLayoutParams(new LayoutParams(-1, -1));
    return root;
}
 
Example 5
Source File: YayaEmoGridViewAdapter.java    From sctalk with Apache License 2.0 6 votes vote down vote up
public GridViewHolder() {
    try {
        LayoutParams layoutParams = new LayoutParams(
                LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
        layoutView = new LinearLayout(context);
        faceIv = new ImageView(context);
        layoutView.setLayoutParams(layoutParams);
        layoutView.setOrientation(LinearLayout.VERTICAL);
        layoutView.setGravity(Gravity.CENTER);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                105,
                115);
        params.gravity = Gravity.CENTER;
        layoutView.addView(faceIv, params);
    } catch (Exception e) {
        logger.e(e.getMessage());
    }
}
 
Example 6
Source File: ImageActivity.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
private void b(String s1, int i1)
{
    Toast toast = Toast.makeText(this, s1, 1);
    LinearLayout linearlayout = (LinearLayout)toast.getView();
    ((TextView)linearlayout.getChildAt(0)).setPadding(8, 0, 0, 0);
    ImageView imageview = new ImageView(this);
    imageview.setLayoutParams(new android.widget.LinearLayout.LayoutParams(com.tencent.connect.avatar.c.a(this, 16F), com.tencent.connect.avatar.c.a(this, 16F)));
    if (i1 == 0)
    {
        imageview.setImageDrawable(b("com.tencent.plus.ic_success.png"));
    } else
    {
        imageview.setImageDrawable(b("com.tencent.plus.ic_error.png"));
    }
    linearlayout.addView(imageview, 0);
    linearlayout.setOrientation(0);
    linearlayout.setGravity(17);
    toast.setView(linearlayout);
    toast.setGravity(17, 0, 0);
    toast.show();
}
 
Example 7
Source File: HashtagView.java    From hashtag-view with MIT License 5 votes vote down vote up
private ViewGroup getRowLayout(int weightSum) {
    LinearLayout rowLayout = new LinearLayout(getContext());
    rowLayout.setLayoutParams(rowLayoutParams);
    rowLayout.setOrientation(HORIZONTAL);
    rowLayout.setGravity(rowGravity);
    rowLayout.setWeightSum(weightSum);
    return rowLayout;
}
 
Example 8
Source File: BarChart.java    From BarChart with Apache License 2.0 5 votes vote down vote up
private void initVerticalChart() {
    verticalLinearParent = new LinearLayout(context);
    verticalLinearParent.setOrientation(LinearLayout.HORIZONTAL);
    verticalLinearParent.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    verticalLinearParent.setGravity(Gravity.BOTTOM);
    if (isShowAnimation) {
        verticalLinearParent.setLayoutTransition(new LayoutTransition());
    }
    this.addView(verticalLinearParent);
}
 
Example 9
Source File: ActivityLogTabs.java    From LibreTasks with Apache License 2.0 5 votes vote down vote up
/**
 * This function will be called once for every element in the listView control, when it needs to
 * draw itself. It should return a constructed view representing the data in the position
 * specified. Each element in the listView is a Log item, so we display the Log's icon and
 * title.
 * 
 * TODO: Use convertView when possible instead of always creating new views.
 */
public View getView(int position, View convertView, ViewGroup parent) {
  LinearLayout ll = new LinearLayout(context);
  ll.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
      LayoutParams.FILL_PARENT));
  ll.setMinimumHeight(50);
  ll.setOrientation(LinearLayout.HORIZONTAL);
  ll.setGravity(Gravity.CENTER_VERTICAL);

  // Icon of the log.
  ImageView iv = new ImageView(context);
  iv.setImageResource(logs.get(position).getIconResId());
  iv.setAdjustViewBounds(true);
  iv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.WRAP_CONTENT,
      LayoutParams.WRAP_CONTENT));
  if (listView.getCheckedItemPosition() == position) {
    iv.setBackgroundResource(R.drawable.icon_hilight);
  }

  // Title of the log.
  TextView tv = new TextView(context);
  tv.setText(logs.get(position).getText());
  tv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
      LayoutParams.FILL_PARENT));
  tv.setGravity(Gravity.CENTER_VERTICAL);
  tv.setPadding(10, 0, 0, 0);
  tv.setTextSize(14.0f);
  tv.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
  tv.setTextColor(context.getResources().getColor(R.color.list_element_text));
  tv.setMinHeight(46);

  ll.addView(iv);
  ll.addView(tv);
  return ll;
}
 
Example 10
Source File: TabLayoutHelper.java    From android-tablayouthelper with Apache License 2.0 5 votes vote down vote up
protected void adjustTabModeInternal(@NonNull TabLayout tabLayout, int prevScrollX) {
    int prevTabMode = tabLayout.getTabMode();

    tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
    tabLayout.setTabGravity(TabLayout.GRAVITY_CENTER);

    int newTabMode = determineTabMode(tabLayout);

    cancelPendingUpdateScrollPosition();

    if (newTabMode == TabLayout.MODE_FIXED) {
        tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
        tabLayout.setTabMode(TabLayout.MODE_FIXED);
    } else {
        LinearLayout slidingTabStrip = (LinearLayout) tabLayout.getChildAt(0);
        slidingTabStrip.setGravity(Gravity.CENTER_HORIZONTAL);
        if (prevTabMode == TabLayout.MODE_SCROLLABLE) {
            // restore scroll position
            tabLayout.scrollTo(prevScrollX, 0);
        } else {
            // scroll to current selected tab
            mUpdateScrollPositionRunnable = new Runnable() {
                @Override
                public void run() {
                    mUpdateScrollPositionRunnable = null;
                    updateScrollPosition();
                }
            };
            mTabLayout.post(mUpdateScrollPositionRunnable);
        }
    }
}
 
Example 11
Source File: WheelItem.java    From WheelView with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化
 */
private void init() {
    LinearLayout layout = new LinearLayout(getContext());
    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT,
            WheelUtils.dip2px(getContext(),
            WheelConstants
                    .WHEEL_ITEM_HEIGHT));
    layout.setOrientation(LinearLayout.HORIZONTAL);
    layout.setPadding(WheelConstants.WHEEL_ITEM_PADDING, WheelConstants.WHEEL_ITEM_PADDING,
            WheelConstants
            .WHEEL_ITEM_PADDING, WheelConstants.WHEEL_ITEM_PADDING);
    layout.setGravity(Gravity.CENTER);
    addView(layout, layoutParams);

    // 图片
    mImage = new ImageView(getContext());
    mImage.setTag(WheelConstants.WHEEL_ITEM_IMAGE_TAG);
    mImage.setVisibility(View.GONE);
    LayoutParams imageParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    imageParams.rightMargin = WheelConstants.WHEEL_ITEM_MARGIN;
    layout.addView(mImage, imageParams);

    // 文本
    mText = new TextView(getContext());
    mText.setTag(WheelConstants.WHEEL_ITEM_TEXT_TAG);
    mText.setEllipsize(TextUtils.TruncateAt.END);
    mText.setSingleLine();
    mText.setIncludeFontPadding(false);
    mText.setGravity(Gravity.CENTER);
    mText.setTextColor(Color.BLACK);
    LayoutParams textParams = new LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT);
    layout.addView(mText, textParams);
}
 
Example 12
Source File: HeaderView.java    From RefreshLayout with Apache License 2.0 5 votes vote down vote up
private void init() {
    LinearLayout content = new LinearLayout(getContext());
    content.setGravity(Gravity.CENTER);
    content.setOrientation(LinearLayout.HORIZONTAL);
    mContent = content;
    LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    addView(mContent, lp);
    initContentView();
}
 
Example 13
Source File: SwipeMenuView.java    From SwipeRecyclerView-master with Apache License 2.0 5 votes vote down vote up
public void createMenu(SwipeMenu swipeMenu, SwipeSwitch swipeSwitch,
                       SwipeMenuItemClickListener swipeMenuItemClickListener,
                       @SwipeMenuRecyclerView.DirectionMode int direction) {
    removeAllViews();

    this.mSwipeSwitch = swipeSwitch;
    this.mItemClickListener = swipeMenuItemClickListener;
    this.mDirection = direction;

    List<SwipeMenuItem> items = swipeMenu.getMenuItems();
    for (int i = 0; i < items.size(); i++) {
        SwipeMenuItem item = items.get(i);

        LayoutParams params = new LayoutParams(item.getWidth(), item.getHeight());
        params.weight = item.getWeight();
        LinearLayout parent = new LinearLayout(getContext());
        parent.setId(i);
        parent.setGravity(Gravity.CENTER);
        parent.setOrientation(VERTICAL);
        parent.setLayoutParams(params);
        ViewCompat.setBackground(parent, item.getBackground());
        parent.setOnClickListener(this);
        addView(parent);

        SwipeMenuBridge menuBridge = new SwipeMenuBridge(mDirection, i, mSwipeSwitch, parent);
        parent.setTag(menuBridge);

        if (item.getImage() != null) {
            ImageView iv = createIcon(item);
            menuBridge.mImageView = iv;
            parent.addView(iv);
        }

        if (!TextUtils.isEmpty(item.getText())) {
            TextView tv = createTitle(item);
            menuBridge.mTextView = tv;
            parent.addView(tv);
        }
    }
}
 
Example 14
Source File: TitleBar.java    From titlebar with Apache License 2.0 5 votes vote down vote up
private void initView(Context context) {
    mLeftText = new TextView(context);
    mCenterLayout = new LinearLayout(context);
    mRightLayout = new LinearLayout(context);
    mDividerView = new View(context);

    LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);

    mLeftText.setTextSize(DEFAULT_ACTION_TEXT_SIZE);
    mLeftText.setSingleLine();
    mLeftText.setGravity(Gravity.CENTER_VERTICAL);
    mLeftText.setPadding(mOutPadding + mActionPadding, 0, mOutPadding, 0);

    mCenterText = new TextView(context);
    mSubTitleText = new TextView(context);
    mCenterLayout.addView(mCenterText);
    mCenterLayout.addView(mSubTitleText);

    mCenterLayout.setGravity(Gravity.CENTER);
    mCenterText.setTextSize(DEFAULT_MAIN_TEXT_SIZE);
    mCenterText.setSingleLine();
    mCenterText.setGravity(Gravity.CENTER);
    mCenterText.setEllipsize(TextUtils.TruncateAt.END);

    mSubTitleText.setTextSize(DEFAULT_SUB_TEXT_SIZE);
    mSubTitleText.setSingleLine();
    mSubTitleText.setGravity(Gravity.CENTER);
    mSubTitleText.setEllipsize(TextUtils.TruncateAt.END);

    mRightLayout.setPadding(mOutPadding, 0, mOutPadding, 0);

    addView(mLeftText, layoutParams);
    addView(mCenterLayout);
    addView(mRightLayout, layoutParams);
    addView(mDividerView, new LayoutParams(LayoutParams.MATCH_PARENT, 1));
}
 
Example 15
Source File: NormalListDialog.java    From FlycoDialog_Master with MIT License 4 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final DialogMenuItem item = mContents.get(position);

    LinearLayout llItem = new LinearLayout(mContext);
    llItem.setOrientation(LinearLayout.HORIZONTAL);
    llItem.setGravity(Gravity.CENTER_VERTICAL);

    ImageView ivItem = new ImageView(mContext);
    ivItem.setPadding(0, 0, dp2px(15), 0);
    llItem.addView(ivItem);

    TextView tvItem = new TextView(mContext);
    tvItem.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    tvItem.setSingleLine(true);
    tvItem.setTextColor(mItemTextColor);
    tvItem.setTextSize(TypedValue.COMPLEX_UNIT_SP, mItemTextSize);

    llItem.addView(tvItem);
    float radius = dp2px(mCornerRadius);
    if (mIsTitleShow) {
        llItem.setBackgroundDrawable((CornerUtils.listItemSelector(radius, Color.TRANSPARENT, mItemPressColor,
                position == mContents.size() - 1)));
    } else {
        llItem.setBackgroundDrawable(CornerUtils.listItemSelector(radius, Color.TRANSPARENT, mItemPressColor,
                mContents.size(), position));
    }

    int left = item.mResId == 0 ? dp2px(18) : dp2px(16);
    int top = dp2px(10);
    int right = 0;
    int bottom = dp2px(10);
    llItem.setPadding(left + mItemExtraLeft, top + mItemExtraTop, right + mItemExtraRight, bottom + mItemExtraBottom);

    ivItem.setImageResource(item.mResId);
    tvItem.setText(item.mOperName);
    ivItem.setVisibility(item.mResId == 0 ? View.GONE : View.VISIBLE);

    return llItem;
}
 
Example 16
Source File: PbChatActivity.java    From imsdk-android with MIT License 4 votes vote down vote up
/**
 * 未读消息数提示
 * isNew 是否是新消息
 */
@SuppressLint("ObjectAnimatorBinding")
public void showUnreadView(int unread) {
    if (unread <= 0 || isFinishing()) {
        return;
    }

    ImageView tipImage = new ImageView(PbChatActivity.this);
    tipImage.setImageResource(R.drawable.atom_ui_chat_unread_tip);

    final TextView textView = new TextView(PbChatActivity.this);
    int padding = Utils.dipToPixels(PbChatActivity.this, 4);
    int size = Utils.dipToPixels(PbChatActivity.this, 30);
    int topMargin = Utils.dipToPixels(PbChatActivity.this, 30);
    final LinearLayout linearLayout = new LinearLayout(PbChatActivity.this);
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);
    linearLayout.setGravity(Gravity.CENTER_VERTICAL);
    linearLayout.setBackgroundResource(R.drawable.atom_ui_float_tab);
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            size);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    layoutParams.setMargins(0, topMargin, 0, 0);
    linearLayout.setPadding(padding * 2, padding, padding * 2, padding);
    linearLayout.setLayoutParams(layoutParams);
    textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13);
    textView.setTextColor(Color.parseColor("#666666"));

    String msg = unread + (String) getText(R.string.atom_ui_tip_unread_message);
    textView.setText(msg);
    textView.setPadding(padding*2, 0, 0, 0);
    textView.setOnClickListener((view) -> {
        chat_region.getRefreshableView().smoothScrollToPosition(pbChatViewAdapter.getCount() - unreadMsgCount.intValue() - 1);
        clearUnread();
    });
    linearLayout.addView(tipImage);
    linearLayout.addView(textView);
    linearLayout.setTag(TAG_UNREAD_VIEW);
    final LayoutTransition layoutTransition = new LayoutTransition();
    layoutTransition.setAnimator(LayoutTransition.APPEARING, ObjectAnimator.ofFloat(this, "scaleX", 0, 1));
    getHandler().postDelayed(() -> {
        if(!isFinishing()){
            chating_view.setLayoutTransition(layoutTransition);
            chating_view.addView(linearLayout);
        }
    }, 500);
}
 
Example 17
Source File: WriteTag.java    From MifareClassicTool with GNU General Public License v3.0 4 votes vote down vote up
/**
 * This method is triggered by {@link #checkTag()} and writes a dump
 * to a tag.
 * @param writeOnPos A map within a map (all with type = Integer).
 * The key of the outer map is the sector number and the value is another
 * map with key = block number and value = write information. The write
 * information must be filtered (by {@link #checkTag()}) return values
 * of {@link MCReader#isWritableOnPositions(HashMap, SparseArray)}.<br />
 * Attention: This method does not any checking. The position and write
 * information must be checked by {@link #checkTag()}.
 * @param keyMap A key map generated by {@link KeyMapCreator}.
 */
private void writeDump(
        final HashMap<Integer, HashMap<Integer, Integer>> writeOnPos,
        final SparseArray<byte[][]> keyMap) {
    // Check for write data.
    if (writeOnPos.size() == 0) {
        // Nothing to write. Exit.
        Toast.makeText(this, R.string.info_nothing_to_write,
                Toast.LENGTH_LONG).show();
        return;
    }

    // Create reader.
    final MCReader reader = Common.checkForTagAndCreateReader(this);
    if (reader == null) {
        return;
    }

    // Display don't remove warning.
    LinearLayout ll = new LinearLayout(this);
    int pad = Common.dpToPx(10);
    ll.setPadding(pad, pad, pad, pad);
    ll.setGravity(Gravity.CENTER);
    ProgressBar progressBar = new ProgressBar(this);
    progressBar.setIndeterminate(true);
    pad = Common.dpToPx(5);
    progressBar.setPadding(0, 0, pad, 0);
    TextView tv = new TextView(this);
    tv.setText(getString(R.string.dialog_wait_write_tag));
    tv.setTextSize(18);
    ll.addView(progressBar);
    ll.addView(tv);
    final AlertDialog warning = new AlertDialog.Builder(this)
        .setTitle(R.string.dialog_wait_write_tag_title)
        .setView(ll)
        .create();
    warning.show();


    // Start writing in new thread.
    final Activity a = this;
    final Handler handler = new Handler();
    new Thread(() -> {
        // Write dump to tag.
        for (int sector : writeOnPos.keySet()) {
            byte[][] keys = keyMap.get(sector);
            for (int block : writeOnPos.get(sector).keySet()) {
                // Select key with write privileges.
                byte writeKey[] = null;
                boolean useAsKeyB = true;
                int wi = writeOnPos.get(sector).get(block);
                if (wi == 1 || wi == 4) {
                    writeKey = keys[0]; // Write with key A.
                    useAsKeyB = false;
                } else if (wi == 2 || wi == 5 || wi == 6) {
                    writeKey = keys[1]; // Write with key B.
                }

                // Write block.
                int result = reader.writeBlock(sector, block,
                        mDumpWithPos.get(sector).get(block),
                        writeKey, useAsKeyB);

                if (result != 0) {
                    // Error. Some error while writing.
                    handler.post(() -> Toast.makeText(a,
                            R.string.info_write_error,
                            Toast.LENGTH_LONG).show());
                    reader.close();
                    warning.cancel();
                    return;
                }
            }
        }
        // Finished writing.
        reader.close();
        warning.cancel();
        handler.post(() -> Toast.makeText(a, R.string.info_write_successful,
                Toast.LENGTH_LONG).show());
        a.finish();
    }).start();
}
 
Example 18
Source File: ListFragment.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Provide default implementation to return a simple list view.  Subclasses
 * can override to replace with their own layout.  If doing so, the
 * returned view hierarchy <em>must</em> have a ListView whose id
 * is {@link android.R.id#list android.R.id.list} and can optionally
 * have a sibling view id {@link android.R.id#empty android.R.id.empty}
 * that is to be shown when the list is empty.
 * 
 * <p>If you are overriding this method with your own custom content,
 * consider including the standard layout {@link android.R.layout#list_content}
 * in your layout file, so that you continue to retain all of the standard
 * behavior of ListFragment.  In particular, this is currently the only
 * way to have the built-in indeterminant progress state be shown.
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    final Context context = getActivity();

    FrameLayout root = new FrameLayout(context);

    // ------------------------------------------------------------------

    LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);

    ProgressBar progress = new ProgressBar(context, null,
            android.R.attr.progressBarStyleLarge);
    pframe.addView(progress, new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));

    root.addView(pframe, new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

    // ------------------------------------------------------------------

    FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);
    
    TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    
    ListView lv = new ListView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    
    // ------------------------------------------------------------------

    root.setLayoutParams(new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    
    return root;
}
 
Example 19
Source File: ProfileEditActivity.java    From YiBo with Apache License 2.0 4 votes vote down vote up
private void initComponents() {
	LinearLayout llHeaderBase = (LinearLayout)findViewById(R.id.llHeaderBase);
   	ThemeUtil.setSecondaryHeader(llHeaderBase);
   	
   	//个人资料头部
   	LinearLayout llProfileHeader = (LinearLayout)findViewById(R.id.llProfileHeader);
	tvScreenName = (TextView)findViewById(R.id.tvScreenName);
	ivVerify = (ImageView)findViewById(R.id.ivVerify);
	tvImpress = (TextView)findViewById(R.id.tvImpress);
	ThemeUtil.setHeaderProfile(llProfileHeader);
	Theme theme = ThemeUtil.createTheme(this);
	tvScreenName.setTextColor(theme.getColor("highlight"));
	ivVerify.setImageDrawable(GlobalResource.getIconVerification(this));
	tvImpress.setTextColor(theme.getColor("content"));
	
	//内容编辑
	ScrollView llContentPanel = (ScrollView)findViewById(R.id.llContentPanel);
	LinearLayout llChangeProfilePhoto = (LinearLayout)findViewById(R.id.llChangeProfilePhoto);
	ImageView ivProfileEdit = (ImageView)findViewById(R.id.ivProfileEdit);
	TextView tvProfileEdit = (TextView)findViewById(R.id.tvProfileEdit);
	etScreenName = (EditText) this.findViewById(R.id.etProfileScreenName);
	etDescription = (EditText) this.findViewById(R.id.etProfileDescription);
	llContentPanel.setBackgroundColor(theme.getColor("background_content"));
	llChangeProfilePhoto.setBackgroundDrawable(theme.getDrawable("selector_btn_action_negative"));
	ivProfileEdit.setImageDrawable(theme.getDrawable("icon_profile_edit"));
	tvProfileEdit.setTextColor(theme.getColorStateList("selector_btn_action_negative"));
	etScreenName.setBackgroundDrawable(theme.getDrawable("selector_input_frame"));
	int content = theme.getColor("content");
	etScreenName.setTextColor(content);
	etDescription.setBackgroundDrawable(theme.getDrawable("selector_input_frame"));
	etDescription.setTextColor(content);
	
	//工具条
       LinearLayout llToolbar = (LinearLayout)findViewById(R.id.llToolbar);
       Button btnProfileUpdate = (Button)findViewById(R.id.btnProfileUpdate);
       Button btnProfileReset = (Button)findViewById(R.id.btnProfileReset);
       llToolbar.setBackgroundDrawable(theme.getDrawable("bg_toolbar"));
       llToolbar.setGravity(Gravity.CENTER);
       int padding4 = theme.dip2px(4);
       llToolbar.setPadding(padding4, padding4, padding4, padding4);
       ThemeUtil.setBtnActionPositive(btnProfileUpdate);
       ThemeUtil.setBtnActionNegative(btnProfileReset);        
	
	profileTextWatcher = new ProfileTextWatcher(this);
	Button btnFollow = (Button) this.findViewById(R.id.btnFollow);
	btnFollow.setVisibility(View.INVISIBLE);
}
 
Example 20
Source File: AbstractMessage.java    From iGap-Android with GNU Affero General Public License v3.0 4 votes vote down vote up
@CallSuper
    protected void updateLayoutForSend(VH holder) {

        ViewGroup frameLayout = (ViewGroup) holder.itemView.findViewById(R.id.mainContainer);
        ((FrameLayout.LayoutParams) frameLayout.getLayoutParams()).gravity = Gravity.RIGHT;
        LinearLayout root = (LinearLayout) holder.itemView.findViewById(R.id.contentContainer);

        ((LinearLayout.LayoutParams) root.getLayoutParams()).gravity = Gravity.RIGHT;

        LinearLayout timeLayout = (LinearLayout) root.getParent();
        timeLayout.setGravity(Gravity.RIGHT);

        ImageView imgTick = (ImageView) holder.itemView.findViewById(R.id.cslr_txt_tic);
        TextView messageText = (TextView) holder.itemView.findViewById(R.id.messageSenderTextMessage);
        //  TextView iconHearing = (TextView) holder.itemView.findViewById(R.id.cslr_txt_hearing);

        if (messageText != null) {
            messageText.setTextColor(Color.parseColor(G.textBubble));
        }
        //   ProtoGlobal.RoomMessageType messageType = mMessage.forwardedFrom == null ? mMessage.messageType : mMessage.forwardedFrom.getMessageType();


        ProtoGlobal.RoomMessageStatus status = ProtoGlobal.RoomMessageStatus.UNRECOGNIZED;
        if (mMessage.status != null) {
            try {
                status = ProtoGlobal.RoomMessageStatus.valueOf(mMessage.status);
            } catch (RuntimeException e) {
                e.printStackTrace();
            }
        }

        if (status == ProtoGlobal.RoomMessageStatus.SEEN) {
            if (G.isDarkTheme) {
                setTextColor(imgTick, R.color.iGapColor);
            } else {
                setTextColor(imgTick, R.color.backgroundColorCall2);
            }

        } else if (status == ProtoGlobal.RoomMessageStatus.LISTENED) {
            // iconHearing.setVisibility(View.VISIBLE);
            if (G.isDarkTheme) {
                setTextColor(imgTick, R.color.iGapColor);
            } else {
                setTextColor(imgTick, R.color.backgroundColorCall2);
            }

            imgTick.setVisibility(View.VISIBLE);
        } else {
//            setTextColor(imgTick, Color.parseColor(G.txtIconCheck));
            imgTick.setColorFilter(Color.parseColor(G.txtIconCheck));
        }


        if (G.isDarkTheme) {
            ((View) (holder.itemView.findViewById(R.id.contentContainer)).getParent()).setBackgroundResource(R.drawable.rectangle_send_round_color_dark);
        } else {
            ((View) (holder.itemView.findViewById(R.id.contentContainer)).getParent()).setBackgroundResource(R.drawable.rectangle_send_round_color);
        }
        GradientDrawable circleDarkColor = (GradientDrawable) ((View) root.getParent()).getBackground();
        circleDarkColor.setColor(Color.parseColor(G.bubbleChatSend));

        /**
         * add main layout margin to prevent getting match parent completely
         * set to mainContainer not itemView because of selecting item foreground
         */
        ((FrameLayout.LayoutParams) frameLayout.getLayoutParams()).leftMargin = (int) holder.itemView.getContext().getResources().getDimension(R.dimen.dp28);
        ((FrameLayout.LayoutParams) frameLayout.getLayoutParams()).rightMargin = (int) holder.itemView.getContext().getResources().getDimension(R.dimen.dp10);

        //((LinearLayout.LayoutParams) (holder.itemView.findViewById(R.id.contentContainer).getLayoutParams())).rightMargin = (int) holder.itemView.getResources().getDimension(R.dimen.messageBox_minusLeftRightMargin);
        //((LinearLayout.LayoutParams) (holder.itemView.findViewById(R.id.contentContainer).getLayoutParams())).leftMargin = 0;
    }