Search in sources :

Example 91 with LayoutParams

use of android.support.v7.widget.RecyclerView.LayoutParams in project Small by wequick.

the class WebActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    int theme = Small.getWebActivityTheme();
    if (theme != 0)
        setTheme(theme);
    boolean fullscreen = false;
    CharSequence queryTitle;
    Uri uri = Small.getUri(this);
    if (uri != null) {
        String param = uri.getQueryParameter("_fullscreen");
        if (param != null) {
            fullscreen = param.equals("1");
        }
        queryTitle = uri.getQueryParameter("_title");
        if (queryTitle != null) {
            super.setTitle(queryTitle);
            mCanSetTitle = false;
        }
    }
    // Init actionBar
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        if (fullscreen) {
            actionBar.hide();
        } else {
            actionBar.show();
            Activity parent = getParent();
            if (parent == null) {
                // If is created by a LocalActivityManager, parent is not null
                actionBar.setDisplayHomeAsUpEnabled(true);
            }
        }
    }
    mFullscreen = fullscreen;
    // Initialize content wrapper
    RelativeLayout wrapper = new RelativeLayout(this);
    wrapper.setGravity(Gravity.CENTER);
    setContentView(wrapper);
    // Initialize webView
    mWebView = new WebView(this);
    ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    wrapper.addView(mWebView, 0, layoutParams);
    // Try to load title from cache
    mUrl = getIntent().getStringExtra("url");
    if (mCanSetTitle) {
        CharSequence title = getCacheTitle(mUrl);
        if (title != null) {
            super.setTitle(title);
        }
    }
}
Also used : ViewGroup(android.view.ViewGroup) RelativeLayout(android.widget.RelativeLayout) AppCompatActivity(android.support.v7.app.AppCompatActivity) Activity(android.app.Activity) Uri(android.net.Uri) ActionBar(android.support.v7.app.ActionBar)

Example 92 with LayoutParams

use of android.support.v7.widget.RecyclerView.LayoutParams in project MagicaSakura by Bilibili.

the class MainActivity method onCreate.

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(null);
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler);
    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    layoutManager.setSmoothScrollbarEnabled(true);
    assert recyclerView != null;
    recyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {

        @Override
        public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
            final int padding = getResources().getDimensionPixelOffset(R.dimen.padding_half);
            RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) view.getLayoutParams();
            final int position = layoutParams.getViewLayoutPosition();
            if (position == 0) {
                outRect.left = outRect.top = outRect.right = padding;
                outRect.bottom = padding >> 1;
            } else if (position == state.getItemCount() - 1) {
                outRect.left = outRect.bottom = outRect.right = padding;
                outRect.top = padding >> 1;
            } else {
                outRect.left = outRect.right = padding;
                outRect.top = outRect.bottom = padding >> 1;
            }
        }
    });
    recyclerView.setLayoutManager(layoutManager);
    Adapter adapter = new Adapter();
    recyclerView.setAdapter(adapter);
    adapter.addViewHolderType(ViewHolder.VIEW_HOLDER_HEADER, ViewHolder.VIEW_HOLDER_LABEL, ViewHolder.VIEW_HOLDER_HEADER, ViewHolder.VIEW_HOLDER_LOGIN, ViewHolder.VIEW_HOLDER_HEADER, ViewHolder.VIEW_HOLDER_DOWNLOAD);
}
Also used : Rect(android.graphics.Rect) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) TintImageView(com.bilibili.magicasakura.widgets.TintImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) Toolbar(android.support.v7.widget.Toolbar)

Example 93 with LayoutParams

use of android.support.v7.widget.RecyclerView.LayoutParams in project Atom_Android by Rogrand-Dev.

the class ShowImageAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
    //动态计算照片的宽度进行显示
    RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holder.imageView.getLayoutParams();
    layoutParams.width = (DensityUtils.getScreenWidth(mContext) - DensityUtils.dp2px(mContext, 6) * 2) / 3;
    layoutParams.height = layoutParams.width;
    holder.imageView.setLayoutParams(layoutParams);
    if (getItemViewType(position) == TYPE_SELECT) {
        holder.imageView.setImageResource(R.drawable.ic_add_service_pic);
        holder.imageView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (onItemControlListener != null) {
                    onItemControlListener.onItemControl(TYPE_SELECT, holder.getAdapterPosition());
                }
            }
        });
        holder.mDelete.setVisibility(View.GONE);
    } else {
        holder.mDelete.setVisibility(View.VISIBLE);
        holder.mDelete.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (onItemControlListener != null) {
                    onItemControlListener.onItemControl(TYPE_SHOW, holder.getAdapterPosition());
                }
            }
        });
        LocalMedia media = mAllDatas.get(position);
        String path = "";
        if (media.isCut() && !media.isCompressed()) {
            //裁剪过
            path = media.getCutPath();
        } else if (media.isCompressed() || (media.isCut() && media.isCompressed())) {
            //压缩过,或者裁剪过后压缩过,以是否压缩为准
            path = media.getCompressPath();
        } else {
            //原图
            path = media.getPath();
        }
        int type = media.getType();
        switch(type) {
            case 1:
                //图片
                Glide.with(mContext).load(path).centerCrop().placeholder(R.drawable.ic_add_service_pic).diskCacheStrategy(DiskCacheStrategy.ALL).into(holder.imageView);
                break;
            case 2:
                //视频
                Glide.with(mContext).load(path).thumbnail(0.5f).into(holder.imageView);
                break;
        }
    }
}
Also used : RelativeLayout(android.widget.RelativeLayout) LocalMedia(com.yalantis.ucrop.entity.LocalMedia) ImageView(android.widget.ImageView) BindView(butterknife.BindView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 94 with LayoutParams

use of android.support.v7.widget.RecyclerView.LayoutParams in project smartmodule by carozhu.

the class FloatingActionMenu method initCover.

/**
     * 初始化FloatingActionMenu展开后的背景
     */
private void initCover() {
    //创建背景View
    mCover = new View(getContext());
    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    layoutParams.gravity = Gravity.CENTER;
    mCover.setLayoutParams(layoutParams);
    // TODO: 16/8/12 设置背景
    //设置背景颜色为白色
    mCover.setBackgroundColor(ContextCompat.getColor(this.getContext(), R.color.transparent));
    //设置监听,当用户点击背景时, 让FloatingActionMenu收缩
    mCover.setOnClickListener(mOnCoverClickListener);
    //初始化时是全透明
    mCover.setAlpha(0f);
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 95 with LayoutParams

use of android.support.v7.widget.RecyclerView.LayoutParams in project android_frameworks_base by crdroidandroid.

the class NavBarTuner method inflatePreview.

private void inflatePreview(ViewGroup view) {
    Display display = getActivity().getWindowManager().getDefaultDisplay();
    boolean isRotated = display.getRotation() == Surface.ROTATION_90 || display.getRotation() == Surface.ROTATION_270;
    Configuration config = new Configuration(getContext().getResources().getConfiguration());
    boolean isPhoneLandscape = isRotated && (config.smallestScreenWidthDp < 600);
    final float scale = isPhoneLandscape ? PREVIEW_SCALE_LANDSCAPE : PREVIEW_SCALE;
    config.densityDpi = (int) (config.densityDpi * scale);
    mPreview = (PreviewNavInflater) LayoutInflater.from(getContext().createConfigurationContext(config)).inflate(R.layout.nav_bar_tuner_inflater, view, false);
    final ViewGroup.LayoutParams layoutParams = mPreview.getLayoutParams();
    layoutParams.width = (int) ((isPhoneLandscape ? display.getHeight() : display.getWidth()) * scale);
    // Not sure why, but the height dimen is not being scaled with the dp, set it manually
    // for now.
    layoutParams.height = (int) (layoutParams.height * scale);
    if (isPhoneLandscape) {
        int width = layoutParams.width;
        layoutParams.width = layoutParams.height;
        layoutParams.height = width;
    }
    view.addView(mPreview);
    if (isRotated) {
        mPreview.findViewById(R.id.rot0).setVisibility(View.GONE);
        final View rot90 = mPreview.findViewById(R.id.rot90);
    } else {
        mPreview.findViewById(R.id.rot90).setVisibility(View.GONE);
        final View rot0 = mPreview.findViewById(R.id.rot0);
    }
}
Also used : Configuration(android.content.res.Configuration) ViewGroup(android.view.ViewGroup) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) Display(android.view.Display)

Aggregations

View (android.view.View)77 RecyclerView (android.support.v7.widget.RecyclerView)67 ViewGroup (android.view.ViewGroup)21 TextView (android.widget.TextView)21 ImageView (android.widget.ImageView)13 LayoutParams (android.support.v7.widget.RecyclerView.LayoutParams)12 Toolbar (android.support.v7.widget.Toolbar)9 FrameLayout (android.widget.FrameLayout)9 Rect (android.graphics.Rect)8 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)8 BindView (butterknife.BindView)8 ActionMenuView (android.support.v7.widget.ActionMenuView)7 MarginLayoutParams (android.view.ViewGroup.MarginLayoutParams)6 LinearLayout (android.widget.LinearLayout)6 CollapsibleActionView (android.support.v7.view.CollapsibleActionView)5 MenuView (android.support.v7.view.menu.MenuView)5 EditText (android.widget.EditText)5 ImageView (carbon.widget.ImageView)5 TextView (carbon.widget.TextView)5 VirtualLayoutManager (com.alibaba.android.vlayout.VirtualLayoutManager)5