com.zhy.autolayout.utils.AutoUtils Java Examples

The following examples show how to use com.zhy.autolayout.utils.AutoUtils. 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: AutoTabLayout.java    From Aurora with Apache License 2.0 6 votes vote down vote up
private void setUpTabTextSize(Tab tab) {
    if (mTextSize == NO_VALID || tab.getCustomView() != null) return;

    ViewGroup tabGroup = (ViewGroup) getChildAt(0);
    ViewGroup tabContainer = (ViewGroup) tabGroup.getChildAt(tab.getPosition());
    TextView textView = (TextView) tabContainer.getChildAt(1);


    if (AutoUtils.autoed(textView)) {
        return;
    }
    int autoTextSize = 0;
    if (mTextSizeBaseWidth) {
        autoTextSize = AutoUtils.getPercentWidthSize(mTextSize);
    } else {
        autoTextSize = AutoUtils.getPercentHeightSize(mTextSize);
    }


    textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, autoTextSize);
}
 
Example #2
Source File: ListFragment.java    From AutoLayout with Apache License 2.0 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
    ViewHolder holder = null;
    if (convertView == null)
    {
        holder = new ViewHolder();
        convertView = LayoutInflater.from(mContext).inflate(R.layout.list_item, parent, false);
        convertView.setTag(holder);
        //对于listview,注意添加这一行,即可在item上使用高度
        AutoUtils.autoSize(convertView);
    } else
    {
        holder = (ViewHolder) convertView.getTag();
    }

    return convertView;
}
 
Example #3
Source File: ListFragment.java    From AndroidAutoLayout with Apache License 2.0 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
    ViewHolder holder = null;
    if (convertView == null)
    {
        holder = new ViewHolder();
        convertView = LayoutInflater.from(mContext).inflate(R.layout.list_item, parent, false);
        convertView.setTag(holder);
        //对于listview,注意添加这一行,即可在item上使用高度
        AutoUtils.autoSize(convertView);
    } else
    {
        holder = (ViewHolder) convertView.getTag();
    }

    return convertView;
}
 
Example #4
Source File: AutoTabLayout.java    From AndroidAutoLayout with Apache License 2.0 6 votes vote down vote up
private void setUpTabTextSize(Tab tab)
{
    if (mTextSize == NO_VALID || tab.getCustomView() != null) return;

    ViewGroup tabGroup = (ViewGroup) getChildAt(0);
    ViewGroup tabContainer = (ViewGroup) tabGroup.getChildAt(tab.getPosition());
    TextView textView = (TextView) tabContainer.getChildAt(1);


    if (AutoUtils.autoed(textView))
    {
        return;
    }
    int autoTextSize = 0 ;
    if (mTextSizeBaseWidth)
    {
        autoTextSize = AutoUtils.getPercentWidthSize(mTextSize);
    } else
    {
        autoTextSize = AutoUtils.getPercentHeightSize(mTextSize);
    }


    textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, autoTextSize);
}
 
Example #5
Source File: AutoTabLayout.java    From MVPArms with Apache License 2.0 6 votes vote down vote up
private void setUpTabTextSize(Tab tab) {
    if (mTextSize == NO_VALID || tab.getCustomView() != null) {
        return;
    }

    ViewGroup tabGroup = (ViewGroup) getChildAt(0);
    ViewGroup tabContainer = (ViewGroup) tabGroup.getChildAt(tab.getPosition());
    TextView textView = (TextView) tabContainer.getChildAt(1);

    if (AutoUtils.autoed(textView)) {
        return;
    }
    int autoTextSize;
    if (mTextSizeBaseWidth) {
        autoTextSize = AutoUtils.getPercentWidthSize(mTextSize);
    } else {
        autoTextSize = AutoUtils.getPercentHeightSize(mTextSize);
    }

    textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, autoTextSize);
}
 
Example #6
Source File: MetroLayout.java    From AndroidAutoLayout with Apache License 2.0 5 votes vote down vote up
public MetroLayout(Context context, AttributeSet attrs)
{
    super(context, attrs);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MetroLayout);
    mDivider = a.getDimensionPixelOffset(R.styleable.MetroLayout_metro_divider, 0);
    mDivider = AutoUtils.getPercentWidthSizeBigger(mDivider);
    a.recycle();

}
 
Example #7
Source File: BaseDialog.java    From Ticket-Analysis with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    getWindow().requestFeature(Window.FEATURE_NO_TITLE);

    LayoutParams clp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    LayoutInflater layoutInflater = LayoutInflater.from(getContext());

    View content = getContentView(layoutInflater);
    initView(content);
    View layout = getBaseDialogView(layoutInflater);
    AutoUtils.autoSize(layout); //适配

    layout.findViewById(R.id.dialog_top).setOnClickListener(this);
    layout.findViewById(R.id.dialog_bottom).setOnClickListener(this);

    LinearLayout contentLayout = (LinearLayout) layout.findViewById(R.id.dialog_content);
    contentLayout.addView(content, clp);

    setContentView(layout, clp);
    setCancelable(true);
    setCanceledOnTouchOutside(true);


    WindowManager.LayoutParams lParams = getWindow().getAttributes();
    lParams.gravity = Gravity.CENTER;
    lParams.width = LayoutParams.MATCH_PARENT;
    lParams.height = LayoutParams.MATCH_PARENT;
    lParams.alpha = 1.0f;
    lParams.dimAmount = 0.0f;
    getWindow().setWindowAnimations(R.style.dialogWindowAnim);
    getWindow().setAttributes(lParams);
}
 
Example #8
Source File: RecyclerViewGridFragment.java    From AndroidAutoLayout with Apache License 2.0 5 votes vote down vote up
public ViewHolder(View itemView)
        {
            super(itemView);
            Random random = new Random();
            itemView.setBackgroundColor(Color.argb(200, random.nextInt(255), random.nextInt(255), random.nextInt(255)));
            //recyclerview,注意添加这一行
            AutoUtils.autoSize(itemView, AutoAttr.BASE_HEIGHT);
//            Log.e("", itemView.getLayoutParams().width + "  , " + itemView.getLayoutParams().height);
        }
 
Example #9
Source File: RecyclerViewFragment.java    From AndroidAutoLayout with Apache License 2.0 5 votes vote down vote up
@Override
public com.zhy.base.adapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
{
    com.zhy.base.adapter.ViewHolder viewHolder = super.onCreateViewHolder(parent, viewType);
    AutoUtils.autoSize(viewHolder.getConvertView());
    return viewHolder;
}
 
Example #10
Source File: AutoToolbar.java    From AndroidAutoLayout with Apache License 2.0 5 votes vote down vote up
private void setUpTitleTextSize(String name, int val) {
    try {
        //反射 Toolbar 的 TextView
        Field f = getClass().getSuperclass().getDeclaredField(name);
        f.setAccessible(true);
        TextView textView = (TextView) f.get(this);
        if (textView != null) {
            int autoTextSize = AutoUtils.getPercentHeightSize(val);
            textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, autoTextSize);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #11
Source File: BaseViewHolder.java    From AndroidBase with Apache License 2.0 5 votes vote down vote up
public BaseViewHolder(View view) {
    super(view);
    this.views = new SparseArray<View>();
    this.childClickViewIds = new LinkedHashSet<>();
    this.itemChildLongClickViewIds = new LinkedHashSet<>();
    convertView = view;
    AutoUtils.auto(convertView);
}
 
Example #12
Source File: BaseAdapterHelper.java    From AndroidBase with Apache License 2.0 5 votes vote down vote up
protected BaseAdapterHelper(Context context, ViewGroup parent, int layoutId, int position) {
    this.context = context;
    this.position = position;
    this.layoutId = layoutId;
    this.views = new SparseArray<View>();
    convertView = LayoutInflater.from(context) //
            .inflate(layoutId, parent, false);
    convertView.setTag(this);
    //对于listview,注意添加这一行,即可在item上使用高度
    AutoUtils.autoSize(convertView);
}
 
Example #13
Source File: AutoToolbar.java    From MVPArms with Apache License 2.0 5 votes vote down vote up
private void setUpTitleTextSize(String name, int val) {
    try {
        //反射 Toolbar 的 TextView
        Field f = getClass().getSuperclass().getDeclaredField(name);
        f.setAccessible(true);
        TextView textView = (TextView) f.get(this);
        if (textView != null) {
            int autoTextSize = AutoUtils.getPercentHeightSize(val);
            textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, autoTextSize);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #14
Source File: BaseHolder.java    From MVPArms with Apache License 2.0 5 votes vote down vote up
public BaseHolder(View itemView) {
    super(itemView);
    //点击事件
    itemView.setOnClickListener(this);
    //屏幕适配
    if (ThirdViewUtil.isUseAutolayout()) {
        AutoUtils.autoSize(itemView);
    }
    //绑定 ButterKnife
    ThirdViewUtil.bindTarget(this, itemView);
}
 
Example #15
Source File: MetroLayout.java    From AutoLayout with Apache License 2.0 5 votes vote down vote up
public MetroLayout(Context context, AttributeSet attrs)
{
    super(context, attrs);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MetroLayout);
    mDivider = a.getDimensionPixelOffset(R.styleable.MetroLayout_metro_divider, 0);
    mDivider = AutoUtils.getPercentWidthSizeBigger(mDivider);
    a.recycle();

}
 
Example #16
Source File: AutoToolbar.java    From LQRWeChat with MIT License 5 votes vote down vote up
private void setUpTitleTextSize(String name, int val) {
    try {
        //反射 Toolbar 的 TextView
        Field f = getClass().getSuperclass().getDeclaredField(name);
        f.setAccessible(true);
        TextView textView = (TextView) f.get(this);
        if (textView != null) {
            int autoTextSize = AutoUtils.getPercentHeightSize(val);
            textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, autoTextSize);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #17
Source File: MyTagAdapter.java    From LQRBiliBlili with MIT License 5 votes vote down vote up
@Override
public View getView(FlowLayout parent, int position, Summary.DataBean.TagBean tagBean) {
    TextView tv = new TextView(parent.getContext());
    int paddingTopAndBottom = 10;
    int paddingLeftAndRight = 25;
    tv.setPadding(paddingLeftAndRight, paddingTopAndBottom, paddingLeftAndRight, paddingTopAndBottom);
    tv.setText(tagBean.getTag_name());
    tv.setTextSize(12);
    tv.setTextColor(ArmsUtils.getColor(parent.getContext(), R.color.text_title));
    tv.setBackgroundResource(R.drawable.shape_tv_tag_video_detail);
    AutoUtils.auto(tv);
    return tv;
}
 
Example #18
Source File: UIViewHolder.java    From AndroidBase with Apache License 2.0 4 votes vote down vote up
public UIViewHolder(Context context, ViewGroup parent, int layoutId) {
    mContext = context;
    mConvertView = LayoutInflater.from(context).inflate(layoutId, parent, false);
    ButterKnife.bind(this, mConvertView);
    AutoUtils.autoSize(mConvertView);
}
 
Example #19
Source File: AutoAttr.java    From AutoLayout with Apache License 2.0 4 votes vote down vote up
protected int getPercentHeightSize()
{
    return AutoUtils.getPercentHeightSizeBigger(pxVal);
}
 
Example #20
Source File: AutoActionMenuItemView.java    From AndroidAutoLayout with Apache License 2.0 4 votes vote down vote up
private void setUpTitleTextSize() {
    if (mMenuTextSize == -1) return;
    int autoTextSize = AutoUtils.getPercentHeightSize(mMenuTextSize);
    setTextSize(TypedValue.COMPLEX_UNIT_PX, autoTextSize);
}
 
Example #21
Source File: AutoAttr.java    From AutoLayout with Apache License 2.0 4 votes vote down vote up
protected int getPercentWidthSize()
{
    return AutoUtils.getPercentWidthSizeBigger(pxVal);
}
 
Example #22
Source File: RecyclerViewFragment.java    From AutoLayout with Apache License 2.0 4 votes vote down vote up
public ViewHolder(View itemView)
{
    super(itemView);
    //对于listview,注意添加这一行,即可在item上使用高度
    AutoUtils.autoSize(itemView);
}
 
Example #23
Source File: AutoAttr.java    From AndroidAutoLayout with Apache License 2.0 4 votes vote down vote up
protected int getPercentWidthSize()
{
    return AutoUtils.getPercentWidthSizeBigger(pxVal);
}
 
Example #24
Source File: AutoAttr.java    From AndroidAutoLayout with Apache License 2.0 4 votes vote down vote up
protected int getPercentHeightSize()
{
    return AutoUtils.getPercentHeightSizeBigger(pxVal);
}
 
Example #25
Source File: BaseHolder.java    From Aurora with Apache License 2.0 4 votes vote down vote up
public BaseHolder(View itemView) {
    super(itemView);
    itemView.setOnClickListener(this);//点击事件
    if (ThirdViewUtil.USE_AUTOLAYOUT == 1) AutoUtils.autoSize(itemView);//适配
    ThirdViewUtil.bindTarget(this, itemView);//绑定
}