类android.widget.LinearLayout源码实例Demo

下面列出了怎么用android.widget.LinearLayout的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: RxTools-master   文件: RxBaseRoundProgressBar.java
private void setupReverse(LinearLayout layoutProgress) {
    RelativeLayout.LayoutParams progressParams = (RelativeLayout.LayoutParams) layoutProgress.getLayoutParams();
    removeLayoutParamsRule(progressParams);
    if (isReverse) {
        progressParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        // For support with RTL on API 17 or more
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
            progressParams.addRule(RelativeLayout.ALIGN_PARENT_END);
    } else {
        progressParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
        // For support with RTL on API 17 or more
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
            progressParams.addRule(RelativeLayout.ALIGN_PARENT_START);
    }
    layoutProgress.setLayoutParams(progressParams);
}
 
@Override
 public void onCreate(Bundle icicle) {
   super.onCreate(icicle);

   Window window = getWindow();
   window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
   viewLayout = new LinearLayout(this);
   viewLayout.setOrientation(LinearLayout.HORIZONTAL);
   frameLayout = new FrameLayout(this);
   frameLayout.addView(viewLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.FILL_PARENT));
   frameLayout.setBackgroundColor(0xFFFFFFFF); // COLOR_WHITE XXX

   setContentView(frameLayout);
   frameLayout.requestLayout();

   hasSurface = false;
 }
 
源代码3 项目: AndroidVideoSamples   文件: MainActivity.java
@Override
public void onCreate( Bundle savedInstanceState ) {
   super.onCreate( savedInstanceState );

   setContentView( R.layout.activity_main );

   mSelectedVideoLayout = (LinearLayout) findViewById( R.id.selected_video_layout );

   mVideoThumbnail = (ImageView) findViewById( R.id.selected_video_thumbnail );

   mVideoName = (TextView) findViewById( R.id.selected_video_name );

   SharedPreferences settings = getPreferences( Context.MODE_PRIVATE );
   String video = settings.getString( RECENT_VIDEO_KEY, null );
   if ( video != null ) {
      loadUri( Uri.parse( video ) );
   }
}
 
源代码4 项目: TvAppRepo   文件: AdvancedShortcutActivity.java
@Override
public void onIcons(PackedIcon[] icons) {
    if (getResources().getBoolean(R.bool.ENABLE_ICON_PACKS)) {
        Log.d(TAG, icons.length + "<<<");
        // Show all icons for the user to select (or let them do their own)
        LinearLayout iconDialogLayout = (LinearLayout) findViewById(R.id.icon_list);
        iconDialogLayout.requestFocus();
        iconDialogLayout.removeAllViews();
        for (final PackedIcon icon : icons) {
            ImageButton imageButton = new ImageButton(AdvancedShortcutActivity.this);
            imageButton.setImageDrawable(icon.icon);
            imageButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (icon.isBanner) {
                        advancedOptions.setBannerBitmap(icon.getBitmap());
                    } else {
                        advancedOptions.setIconBitmap(icon.getBitmap());
                    }
                    Log.d(TAG, advancedOptions.toString());
                }
            });
            iconDialogLayout.addView(imageButton);
        }
    }
}
 
源代码5 项目: PreferenceFragment   文件: AlertController.java
private void setupContent(LinearLayout contentPanel) {
    mScrollView = (ScrollView) mWindow.findViewById(R.id.scrollView);
    mScrollView.setFocusable(false);
    
    // Special case for users that only want to display a String
    mMessageView = (TextView) mWindow.findViewById(R.id.message);
    if (mMessageView == null) {
        return;
    }
    
    if (mMessage != null) {
        mMessageView.setText(mMessage);
    } else {
        mMessageView.setVisibility(View.GONE);
        mScrollView.removeView(mMessageView);
        
        if (mListView != null) {
            contentPanel.removeView(mWindow.findViewById(R.id.scrollView));
            contentPanel.addView(mListView,
                    new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
            contentPanel.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, 0, 1.0f));
        } else {
            contentPanel.setVisibility(View.GONE);
        }
    }
}
 
源代码6 项目: microMathematics   文件: DialogPaletteSettings.java
private void prepareGroup(Context context, LinearLayout itemLayout, String s, List<String> visibleGroups)
{
    final AppCompatCheckBox cb = itemLayout.findViewById(R.id.dialog_palette_settings_checkbox);
    cb.setTag(s);
    cb.setChecked(visibleGroups.contains(s));
    final LinearLayout buttonLayout = itemLayout.findViewById(R.id.dialog_palette_settings_buttons);
    for (int i = 0; i < buttonLayout.getChildCount(); i++)
    {
        if (buttonLayout.getChildAt(i) instanceof AppCompatImageButton)
        {
            final AppCompatImageButton b = (AppCompatImageButton) buttonLayout.getChildAt(i);
            b.setOnLongClickListener(this);
            ViewUtils.setImageButtonColorAttr(context, b, R.attr.colorDialogContent);
        }
    }
}
 
源代码7 项目: Huochexing12306   文件: A6OrderAty.java
private void initViews() {
	mNavigationIndex = getIntent()
			.getIntExtra(EXTRA_PRE_LOAD_DATA_INDEX, 0);
	llytOperate = (LinearLayout) findViewById(R.id.operate);
	btnCancel = (Button) findViewById(R.id.cancel);
	btnCancel.setOnClickListener(this);
	btnPay = (Button) findViewById(R.id.pay);
	btnPay.setOnClickListener(this);
	tvEmptyView = (TextView) findViewById(R.id.emptyView);
	lvOrders = (ExpandableListView) findViewById(R.id.orders);

	lvOrders.setEmptyView(tvEmptyView);
	LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
	View footerView = inflater.inflate(R.layout.fv_a6_order, null);
	lvOrders.addFooterView(footerView);
	mAdapter = new A6OrderExpandableAdapter(this, mLstODBInfos);
	lvOrders.setAdapter(mAdapter);

	// btnPay.setEnabled(false);
	setPanelGone(true);
}
 
源代码8 项目: o2oa   文件: NickSignActivity.java
private void initView() {
    mEd_sign = (EditText) findViewById(R.id.ed_sign);
    mLl_nickSign = (LinearLayout) findViewById(R.id.ll_nickSign);
    mTv_count = (TextView) findViewById(R.id.tv_count);
    mJmui_commit_btn = (Button) findViewById(R.id.jmui_commit_btn);

    if (getIntent().getStringExtra("group_name") != null) {
        mEd_sign.setText(getIntent().getStringExtra("group_name"));
    }
    if (getIntent().getStringExtra("group_desc") != null) {
        mEd_sign.setText(getIntent().getStringExtra("group_desc"));
    }
    if (getIntent().getStringExtra("old_nick") != null) {
        mEd_sign.setText(getIntent().getStringExtra("old_nick"));
    }
    if (getIntent().getStringExtra("old_sign") != null) {
        mEd_sign.setText(getIntent().getStringExtra("old_sign"));
    }

    mEd_sign.setSelection(mEd_sign.getText().length());

}
 
@Override
protected void onBindDialogView(View view) {

    backgroundType = prefs.getSavedBackgroundColorType();
    backgroundValue = prefs.getSavedBackgroundColor();
    savedCustomColor = prefs.getSavedBackgroundCustomColor();

    linearLayouts = new ArrayList<>();
    linearLayouts.add(view.findViewById(R.id.dialogBackgroundColorBlue));
    linearLayouts.add(view.findViewById(R.id.dialogBackgroundColorGreen));
    linearLayouts.add(view.findViewById(R.id.dialogBackgroundColorRed));
    linearLayouts.add(view.findViewById(R.id.dialogBackgroundColorYellow));
    linearLayouts.add(view.findViewById(R.id.dialogBackgroundColorOrange));
    linearLayouts.add(view.findViewById(R.id.dialogBackgroundColorPurple));

    for (LinearLayout linearLayout : linearLayouts) {
        linearLayout.setOnClickListener(this);
    }

    super.onBindDialogView(view);
}
 
源代码10 项目: AndroidLinkup   文件: EditPage.java
private LinearLayout getPageBody() {
	llBody = new LinearLayout(getContext());
	llBody.setId(2);
	int resId = getBitmapRes(activity, "edittext_back");
	if (resId > 0) {
		llBody.setBackgroundResource(resId);
	}
	llBody.setOrientation(LinearLayout.VERTICAL);
	RelativeLayout.LayoutParams lpBody = new RelativeLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpBody.addRule(RelativeLayout.ALIGN_LEFT, llTitle.getId());
	lpBody.addRule(RelativeLayout.BELOW, llTitle.getId());
	lpBody.addRule(RelativeLayout.ALIGN_RIGHT, llTitle.getId());
	if (!dialogMode) {
		lpBody.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
	}
	int dp_3 = dipToPx(getContext(), 3);
	lpBody.setMargins(dp_3, dp_3, dp_3, dp_3);
	llBody.setLayoutParams(lpBody);

	llBody.addView(getMainBody());
	llBody.addView(getSep());
	llBody.addView(getPlatformList());

	return llBody;
}
 
源代码11 项目: geopaparazzi   文件: ExportActivity.java
protected void addMenuEntries(List<IMenuEntry> entries) {
    menuEntriesMap.clear();
    int code = START_REQUEST_CODE + 1;
    for (final eu.geopaparazzi.library.plugin.types.IMenuEntry entry : entries) {
        final Context context = this;

        Button button = new Button(context);
        LinearLayout.LayoutParams lp = StyleHelper.styleButton(this, button);
        button.setText(entry.getLabel());
        entry.setRequestCode(code);
        menuEntriesMap.put(code, entry);
        code++;
        LinearLayout container = findViewById(R.id.scrollView);
        container.addView(button, lp);
        button.setOnClickListener(new Button.OnClickListener() {
            public void onClick(View v) {
                entry.onClick(ExportActivity.this);
            }
        });
    }
}
 
源代码12 项目: narrate-android   文件: FilterSortDialog.java
private void updateDateText(Dialog dialog) {
    mDateStartText.setText(mStartDate == null ? getString(R.string.start) : mFormatter.format(mStartDate.getTime()));
    mDateEndText.setText(mEndDate == null ? getString(R.string.end) : mFormatter.format(mEndDate.getTime()));

    final LinearLayout filterDateLayout = (LinearLayout) dialog.findViewById(R.id.filter_date_layout);
    final RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) filterDateLayout.getLayoutParams();

    if (mStartDate != null && mEndDate != null) {
        lp.addRule(RelativeLayout.BELOW, R.id.filter_date);
        lp.addRule(RelativeLayout.RIGHT_OF, 0);
        lp.leftMargin = Math.round(getActivity().getResources().getDimensionPixelOffset(R.dimen.checkbox_text_offset));
    } else {
        lp.addRule(RelativeLayout.BELOW, 0);
        lp.addRule(RelativeLayout.RIGHT_OF, R.id.filter_date);
        lp.leftMargin = 0;
    }
    filterDateLayout.setLayoutParams(lp);
}
 
源代码13 项目: AndroidKeyboard   文件: MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    LinearLayout enableSetting = findViewById(R.id.layout_EnableSetting);
    LinearLayout addKeyboards = findViewById(R.id.layout_AddLanguages);
    LinearLayout chooseInputMethod = findViewById(R.id.layout_ChooseInput);
    LinearLayout chooseTheme = findViewById(R.id.layout_ChooseTheme);
    LinearLayout manageDictionaries = findViewById(R.id.layout_ManageDictionary);
    LinearLayout about = findViewById(R.id.layout_about);

    enableSetting.setOnClickListener(this);
    addKeyboards.setOnClickListener(this);
    chooseInputMethod.setOnClickListener(this);
    chooseTheme.setOnClickListener(this);
    manageDictionaries.setOnClickListener(this);
    about.setOnClickListener(this);

    AdView adView = this.findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
            .addTestDevice("D17FE6D8441E3F2375E3709A2EED851B")
            .build();
    adView.loadAd(adRequest);
}
 
源代码14 项目: FileManager   文件: StatusBarUtil.java
/**
 * 为DrawerLayout 布局设置状态栏变色(5.0以下无半透明效果,不建议使用)
 *
 * @param activity 需要设置的activity
 * @param drawerLayout DrawerLayout
 * @param color 状态栏颜色值
 */
public static void setColorForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout,
    int color) {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    // 生成一个状态栏大小的矩形
    View statusBarView = createStatusBarView(activity, color);
    // 添加 statusBarView 到布局中
    ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
    contentLayout.addView(statusBarView, 0);
    // 内容布局不是 LinearLayout 时,设置padding top
    if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) {
      contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0);
    }
    // 设置属性
    ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1);
    drawerLayout.setFitsSystemWindows(false);
    contentLayout.setFitsSystemWindows(false);
    contentLayout.setClipToPadding(true);
    drawer.setFitsSystemWindows(false);
  }
}
 
源代码15 项目: AndroidAll   文件: EditViewInMZActivity.java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);


    setContentView(R.layout.activity_edit_view_mz);
    LinearLayout ll = (LinearLayout) findViewById(R.id.ll_container);
    MZEditText myEditText = new MZEditText(this);

    myEditText.setExtraWidth(11);
    //myEditText.removeExtraWidth();

    myEditText.setBackgroundResource(0);
    myEditText.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_CLASS_NUMBER);
    myEditText.setMaxLines(1);
    myEditText.setSingleLine(true);
    ll.addView(myEditText, 1);

}
 
源代码16 项目: Cirrus_depricated   文件: Preferences.java
@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    getDelegate().onPostCreate(savedInstanceState);

    LinearLayout root = (LinearLayout)findViewById(android.R.id.list).getParent().getParent().getParent();
    Toolbar toolbar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.toolbar, root, false);
    root.addView(toolbar, 0); // insert at top

    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle(R.string.actionbar_settings);

    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });
}
 
源代码17 项目: 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();
}
 
源代码18 项目: Xndroid   文件: BrowserActivity.java
private void initializeToolbarHeight(@NonNull final Configuration configuration) {
    // TODO externalize the dimensions
    doOnLayout(mUiLayout, new Runnable() {
        @Override
        public void run() {
            int toolbarSize;
            if (configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
                // In portrait toolbar should be 56 dp tall
                toolbarSize = Utils.dpToPx(56);
            } else {
                // In landscape toolbar should be 48 dp tall
                toolbarSize = Utils.dpToPx(52);
            }
            mToolbar.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, toolbarSize));
            mToolbar.setMinimumHeight(toolbarSize);
            doOnLayout(mToolbar, new Runnable() {
                @Override
                public void run() {
                    setWebViewTranslation(mToolbarLayout.getHeight());
                }
            });
            mToolbar.requestLayout();

        }
    });
}
 
源代码19 项目: Android_framework   文件: AppDialog.java
private LinearLayout generateLayout(String text){
    LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.dialog_item_button_layout, null);
    View v_line = layout.findViewById(R.id.v_line);
    TextView tv_text = (TextView) layout.findViewById(R.id.tv_text);
    tv_text.setText(text);
    if (ll_bottom_button.getChildCount() == 0){
        layout.removeView(v_line);
        tv_text.setBackgroundResource(R.drawable.dialog_button_bottom_selector);
    }
    else if (ll_bottom_button.getChildCount() == 1){
        tv_text.setBackgroundResource(R.drawable.dialog_button_bottomright_selector);
    }
    else{
        tv_text.setBackgroundResource(R.drawable.dialog_button_bottomright_selector);
    }
    reBuildCircle();
    LinearLayout.LayoutParams params =
            new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    params.weight = 1;
    layout.setLayoutParams(params);
    layout.setOnClickListener(this);
    return layout;
}
 
源代码20 项目: GravityBox   文件: QsDetailItemsList.java
private QsDetailItemsList(LinearLayout view) {
    mView = view;

    mListView = (ListView) mView.findViewById(android.R.id.list);
    mListView.setOnTouchListener(new OnTouchListener() {
        // Setting on Touch Listener for handling the touch inside ScrollView
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // Disallow the touch request for parent scroll on touch of child view
            v.getParent().requestDisallowInterceptTouchEvent(true);
            return false;
        }
    });
    mEmpty = mView.findViewById(android.R.id.empty);
    mEmpty.setVisibility(View.GONE);
    mEmptyText = (TextView) mEmpty.findViewById(android.R.id.title);
    mEmptyIcon = (ImageView) mEmpty.findViewById(android.R.id.icon);
    mListView.setEmptyView(mEmpty);
}
 
private void initView() {
	etSSID = (EditText) findViewById(R.id.etSSID);
	etPsw = (EditText) findViewById(R.id.etPsw);
	llNext = (LinearLayout) findViewById(R.id.llNext);
	cbLaws = (CheckBox) findViewById(R.id.cbLaws);
	imgWiFiList = (ImageView) findViewById(R.id.imgWiFiList);

	if (!TextUtils.isEmpty(workSSID)) {
		etSSID.setText(workSSID);
		if (checkworkSSIDUsed(workSSID)) {
			if (!TextUtils.isEmpty(spf.getString("workSSIDPsw", ""))) {
				etPsw.setText(spf.getString("workSSIDPsw", ""));
			}
		}
	}
}
 
源代码22 项目: EasyVPN-Free   文件: HomeActivity.java
private void initMap() {
    AndroidGraphicFactory.createInstance(getApplication());
    mapView = new MapView(this);

    mapView.setClickable(true);
    mapView.getMapScaleBar().setVisible(false);
    mapView.setBuiltInZoomControls(false);
    mapView.setZoomLevelMin((byte) 2);
    mapView.setZoomLevelMax((byte) 10);

    mapView.setZoomLevel((byte) 2);
    mapView.getModel().displayModel.setBackgroundColor(ContextCompat.getColor(this, R.color.mapBackground));

    layers = mapView.getLayerManager().getLayers();

    MapCreator mapCreator = new MapCreator(this, layers);
    mapCreator.parseGeoJson("world_map.geo.json");

    initServerOnMap(layers);

    LinearLayout map = (LinearLayout) findViewById(R.id.map);
    map.addView(mapView);
}
 
源代码23 项目: TLint   文件: StatusBarUtil.java
/**
 * 为 DrawerLayout 布局设置状态栏透明
 *
 * @param activity     需要设置的activity
 * @param drawerLayout DrawerLayout
 */
public static void setTransparentForDrawerLayout(Activity activity, DrawerLayout drawerLayout) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        return;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
    } else {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }

    ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
    // 内容布局不是 LinearLayout 时,设置padding top
    if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) {
        contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0);
    }

    // 设置属性
    ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1);
    drawerLayout.setFitsSystemWindows(false);
    contentLayout.setFitsSystemWindows(false);
    contentLayout.setClipToPadding(true);
    drawer.setFitsSystemWindows(false);
}
 
源代码24 项目: nono-android   文件: EaseEmojiconScrollTabBar.java
private void init(Context context, AttributeSet attrs){
    this.context = context;
    LayoutInflater.from(context).inflate(R.layout.ease_widget_emojicon_tab_bar, this);
    
    scrollView = (HorizontalScrollView) findViewById(R.id.scroll_view);
    tabContainer = (LinearLayout) findViewById(R.id.tab_container);
}
 
/**
 * Update small notification icons when there is new notification coming, and the
 * Activity is in foreground.
 */
private void updateNotificationIcons() {

    if (mNotificationsContainer.getVisibility() != View.VISIBLE) {
        mNotificationsContainer.setVisibility(View.VISIBLE);
    }

    NotificationHub notificationHub = NotificationHub.getInstance();

    int iconSize = getResources().getDimensionPixelSize(R.dimen.small_notification_icon_size);
    int padding = getResources().getDimensionPixelSize(R.dimen.small_notification_icon_padding);

    final StatusBarNotification n = notificationHub.getCurrentNotification();
    ImageView icon = new ImageView(this);
    icon.setAlpha(NotificationPeek.ICON_LOW_OPACITY);

    icon.setPadding(padding, 0, padding, 0);
    icon.setImageDrawable(NotificationPeekViewUtils.getIconFromResource(this, n));
    icon.setTag(n);

    restoreFirstIconVisibility();

    int oldIndex = getOldIconViewIndex(notificationHub);

    if (oldIndex >= 0) {
        mNotificationsContainer.removeViewAt(oldIndex);
    }

    mNotificationsContainer.addView(icon);
    LinearLayout.LayoutParams linearLayoutParams =
            new LinearLayout.LayoutParams(iconSize, iconSize);

    // Wrap LayoutParams to GridLayout.LayoutParams.
    GridLayout.LayoutParams gridLayoutParams = new GridLayout.LayoutParams(linearLayoutParams);
    icon.setLayoutParams(gridLayoutParams);
}
 
@Test
public void testOnCreateViewHolder() {
    BaseBrick brick = mock(BaseBrick.class);
    when(brick.getLayout()).thenReturn(R.layout.text_brick);

    when(dataManager.brickWithLayout(anyInt())).thenReturn(brick);

    adapter.onCreateViewHolder(new LinearLayout(InstrumentationRegistry.getTargetContext()), brick.getLayout());

    verify(brick).createViewHolder(any(View.class));
}
 
源代码27 项目: KrGallery   文件: LayoutHelper.java
public static LinearLayout.LayoutParams createLinear(int width, int height, float weight,
        int gravity) {
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(getSize(width),
            getSize(height), weight);
    layoutParams.gravity = gravity;
    return layoutParams;
}
 
源代码28 项目: letv   文件: MyMessageTabPageIndicator.java
public void setCurrentItem(int item) {
    if (this.mViewPager != null) {
        if (!(item == -1 || this.mSelectedTabIndex == item)) {
            this.mViewPager.setCurrentItem(item);
        }
        this.mSelectedTabIndex = item;
        int tabCount = this.mTabLayout.getChildCount();
        int i = 0;
        while (i < tabCount) {
            LinearLayout childLayout = (LinearLayout) this.mTabLayout.getChildAt(i);
            for (int j = 0; j < childLayout.getChildCount(); j++) {
                boolean isSelected = i == item;
                View view = childLayout.getChildAt(j);
                if (view instanceof TabView) {
                    view.setSelected(isSelected);
                    if (isSelected) {
                        animateToTab(item);
                        ((TabView) view).setTextColor(this.mContext.getResources().getColor(2131493202));
                    } else {
                        ((TabView) view).setTextColor(this.mContext.getResources().getColor(2131493237));
                    }
                } else if (isSelected) {
                    view.setBackgroundColor(this.mContext.getResources().getColor(2131493202));
                } else {
                    view.setBackgroundDrawable(null);
                }
            }
            i++;
        }
    }
}
 
源代码29 项目: gravitydefied   文件: ActionMenuElement.java
@Override
protected void createAllViews() {
	super.createAllViews();

	Context context = getGDActivity();
	lockImage = new MenuImageView(context);
	lockImage.setScaleType(ImageView.ScaleType.CENTER);
	lockImage.setVisibility(View.GONE);

	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT);
	lp.setMargins(0, 0, getDp(ActionMenuElement.LOCK_IMAGE_MARGIN_RIGHT), 0);
	lockImage.setLayoutParams(lp);

	layout.addView(lockImage, 1);
}
 
源代码30 项目: XERUNG   文件: SearchGroupMember.java
private void findViewIds(){
	mLayback    = (RelativeLayout)findViewById(R.id.layBack);		
	listview    = (ListView)findViewById(R.id.lvList);		
	relProgress = (RelativeLayout)findViewById(R.id.layProgressresult);		
	layMain     = (LinearLayout)findViewById(R.id.layMain);	
	edtSearch   = (EditText)findViewById(R.id.edtGroupSearch);
	txtType = (TextView)findViewById(R.id.txtTypeSearch);
	txtType.setTypeface(ManagerTypeface.getTypeface(SearchGroupMember.this, R.string.typeface_roboto_regular));
}
 
 类所在包
 同包方法