android.widget.LinearLayout#setGravity ( )源码实例Demo

下面列出了android.widget.LinearLayout#setGravity ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: SlideAndDragListView   文件: SDMenuItemView.java
@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());
    }
}
 
源代码2 项目: MiBandDecompiled   文件: ImageActivity.java
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();
}
 
源代码3 项目: sctalk   文件: YayaEmoGridViewAdapter.java
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());
    }
}
 
源代码4 项目: letv   文件: ListFragment.java
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;
}
 
源代码5 项目: AndroidPicker   文件: MultiplePicker.java
@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;
}
 
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));
    }

}
 
源代码7 项目: BarChart   文件: BarChart.java
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);
}
 
源代码8 项目: titlebar   文件: TitleBar.java
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));
}
 
源代码9 项目: SwipeRecyclerView-master   文件: SwipeMenuView.java
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);
        }
    }
}
 
源代码10 项目: RefreshLayout   文件: HeaderView.java
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();
}
 
源代码11 项目: WheelView   文件: WheelItem.java
/**
 * 初始化
 */
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);
}
 
源代码12 项目: android-tablayouthelper   文件: TabLayoutHelper.java
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);
        }
    }
}
 
源代码13 项目: LibreTasks   文件: ActivityLogTabs.java
/**
 * 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;
}
 
源代码14 项目: hashtag-view   文件: HashtagView.java
private ViewGroup getRowLayout(int weightSum) {
    LinearLayout rowLayout = new LinearLayout(getContext());
    rowLayout.setLayoutParams(rowLayoutParams);
    rowLayout.setOrientation(HORIZONTAL);
    rowLayout.setGravity(rowGravity);
    rowLayout.setWeightSum(weightSum);
    return rowLayout;
}
 
源代码15 项目: FlycoDialog_Master   文件: NormalListDialog.java
@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;
}
 
源代码16 项目: imsdk-android   文件: PbChatActivity.java
/**
 * 未读消息数提示
 * 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);
}
 
源代码17 项目: MifareClassicTool   文件: WriteTag.java
/**
 * 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();
}
 
源代码18 项目: CodenameOne   文件: ListFragment.java
/**
 * 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;
}
 
源代码19 项目: YiBo   文件: ProfileEditActivity.java
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);
}
 
源代码20 项目: iGap-Android   文件: AbstractMessage.java
@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;
    }