Java Code Examples for com.zhy.autolayout.utils.AutoUtils

The following examples show how to use com.zhy.autolayout.utils.AutoUtils. These examples are extracted from open source projects. 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 Project: Aurora   Source File: AutoTabLayout.java    License: 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 Project: AutoLayout   Source File: ListFragment.java    License: 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 Project: MVPArms   Source File: AutoTabLayout.java    License: 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 4
Source Project: AndroidAutoLayout   Source File: AutoTabLayout.java    License: 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 Project: AndroidAutoLayout   Source File: ListFragment.java    License: 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 6
Source Project: Ticket-Analysis   Source File: BaseDialog.java    License: 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 7
Source Project: LQRBiliBlili   Source File: MyTagAdapter.java    License: 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 8
Source Project: LQRWeChat   Source File: AutoToolbar.java    License: 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 9
Source Project: AutoLayout   Source File: MetroLayout.java    License: 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 10
Source Project: MVPArms   Source File: BaseHolder.java    License: 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 11
Source Project: MVPArms   Source File: AutoToolbar.java    License: 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 12
Source Project: AndroidBase   Source File: BaseAdapterHelper.java    License: 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 Project: AndroidBase   Source File: BaseViewHolder.java    License: 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 14
Source Project: AndroidAutoLayout   Source File: AutoToolbar.java    License: 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 15
Source Project: AndroidAutoLayout   Source File: RecyclerViewFragment.java    License: 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 16
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 17
Source Project: AndroidAutoLayout   Source File: MetroLayout.java    License: 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 18
Source Project: Aurora   Source File: BaseHolder.java    License: 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);//绑定
}
 
Example 19
Source Project: AutoLayout   Source File: RecyclerViewFragment.java    License: Apache License 2.0 4 votes vote down vote up
public ViewHolder(View itemView)
{
    super(itemView);
    //对于listview,注意添加这一行,即可在item上使用高度
    AutoUtils.autoSize(itemView);
}
 
Example 20
Source Project: AutoLayout   Source File: AutoAttr.java    License: Apache License 2.0 4 votes vote down vote up
protected int getPercentWidthSize()
{
    return AutoUtils.getPercentWidthSizeBigger(pxVal);
}
 
Example 21
Source Project: AutoLayout   Source File: AutoAttr.java    License: Apache License 2.0 4 votes vote down vote up
protected int getPercentHeightSize()
{
    return AutoUtils.getPercentHeightSizeBigger(pxVal);
}
 
Example 22
Source Project: AndroidBase   Source File: UIViewHolder.java    License: 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 23
Source Project: AndroidAutoLayout   Source File: AutoActionMenuItemView.java    License: 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 24
Source Project: AndroidAutoLayout   Source File: AutoAttr.java    License: Apache License 2.0 4 votes vote down vote up
protected int getPercentWidthSize()
{
    return AutoUtils.getPercentWidthSizeBigger(pxVal);
}
 
Example 25
Source Project: AndroidAutoLayout   Source File: AutoAttr.java    License: Apache License 2.0 4 votes vote down vote up
protected int getPercentHeightSize()
{
    return AutoUtils.getPercentHeightSizeBigger(pxVal);
}