LinearLayout typeLayout = (LinearLayout) headerView.findViewById(R.id.layout_type);
final List<FirstTypeEntity.DataBean> firstTypeList = entity.getData();
for (int i = 0;i<firstTypeList.size();i++){
WindowManager wm = (WindowManager) getContext()
.getSystemService(Context.WINDOW_SERVICE);
int width = wm.getDefaultDisplay().getWidth();
int height = wm.getDefaultDisplay().getHeight();
View view = View.inflate(getActivity(),R.layout.item_first_type,null);
LinearLayout tab = (LinearLayout) view.findViewById(R.id.tab);
LinearLayout.LayoutParams linearParams =(LinearLayout.LayoutParams) tab.getLayoutParams();
linearParams.width = width/firstTypeList.size();//根据数量来吧
linearParams.height = width/firstTypeList.size();//根据数量来吧
tab.setLayoutParams(linearParams); //使设置好的布局参数应用到控件
}
<com.zhy.android.percent.support.PercentLinearLayout
android:id="@+id/tab"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:background="@drawable/selector_choose_white">
<ImageView
android:id="@+id/iv"
android:layout_width="0dp"
app:layout_widthPercent="45%h"
android:layout_height="0dp"
app:layout_heightPercent="45%h"
android:src="@mipmap/first_newenergy_tab"/>
<TextView
android:id="@+id/tv"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_heightPercent="20%h"
android:text="新能源"
android:textColor="@color/black_my"
app:layout_textSizePercent="12%"
android:gravity="center"
android:maxLines="1"
android:ellipsize="end"/>
</com.zhy.android.percent.support.PercentLinearLayout>
<com.zhy.android.percent.support.PercentLinearLayout
android:id="@+id/layout_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/white">
</com.zhy.android.percent.support.PercentLinearLayout>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有