优化日志UI
This commit is contained in:
		| @@ -190,6 +190,7 @@ public class LogView extends RelativeLayout { | ||||
|  | ||||
|         // 加载标签表 | ||||
|         mListViewTags = findViewById(cc.winboll.studio.libappbase.R.id.tags_listview); | ||||
|         mListViewTags.setVerticalOffset(10); | ||||
|         mTAGListAdapter = new TAGListAdapter(mContext, mapTAGList); | ||||
|         mListViewTags.setAdapter(mTAGListAdapter); | ||||
|  | ||||
|   | ||||
| @@ -12,7 +12,9 @@ import android.widget.ListView; | ||||
| import cc.winboll.studio.libappbase.LogUtils; | ||||
|  | ||||
| public class HorizontalListView extends ListView { | ||||
|  | ||||
|     public static final String TAG = "HorizontalListView"; | ||||
|     int verticalOffset = 0; | ||||
|  | ||||
|     public HorizontalListView(Context context) { | ||||
|         super(context); | ||||
| @@ -25,25 +27,10 @@ public class HorizontalListView extends ListView { | ||||
|     public HorizontalListView(Context context, AttributeSet attrs, int defStyle) { | ||||
|         super(context, attrs, defStyle); | ||||
|     } | ||||
| //    @Override | ||||
| //    protected void onLayout(boolean changed, int l, int t, int r, int b) { | ||||
| //        super.onLayout(changed, l, t, r, b); | ||||
| //        int childCount = getChildCount(); | ||||
| //        int left = getPaddingLeft(); | ||||
| //        // 获取HorizontalListView的高度 | ||||
| //        int viewHeight = getMeasuredHeight() - getPaddingTop() - getPaddingBottom(); | ||||
| //        for (int i = 0; i < childCount; i++) { | ||||
| //            View child = getChildAt(i); | ||||
| //            int width = child.getMeasuredWidth(); | ||||
| //            int height = child.getMeasuredHeight(); | ||||
| //            // 计算子项在垂直方向上的居中偏移量 | ||||
| //            int verticalOffset = (viewHeight - height) / 2; | ||||
| //            // 设置子视图的位置,实现水平布局并垂直居中 | ||||
| //            child.layout(left, getPaddingTop() + verticalOffset, left + width, getPaddingTop() + verticalOffset + height); | ||||
| //            left += width; | ||||
| //        } | ||||
| //    } | ||||
| //     | ||||
|  | ||||
|     public void setVerticalOffset(int verticalOffset) { | ||||
|         this.verticalOffset = verticalOffset; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected void onLayout(boolean changed, int l, int t, int r, int b) { | ||||
| @@ -52,7 +39,7 @@ public class HorizontalListView extends ListView { | ||||
|         int left = getPaddingLeft(); | ||||
|         int viewHeight = getMeasuredHeight() - getPaddingTop() - getPaddingBottom(); | ||||
|         LogUtils.d(TAG, String.format("HorizontalListView的高度 %d", viewHeight)); | ||||
|         int verticalOffset = 20; | ||||
|          | ||||
|         for (int i = 0; i < childCount; i++) { | ||||
|             View child = getChildAt(i); | ||||
|             // 计算每个子视图的宽度和高度 | ||||
| @@ -60,7 +47,7 @@ public class HorizontalListView extends ListView { | ||||
|             int height = child.getMeasuredHeight(); | ||||
|             //LogUtils.d(TAG, String.format("child : width %d , height %d", width, height)); | ||||
|             // 设置子视图的位置,实现水平布局 | ||||
|              | ||||
|  | ||||
|             child.layout(left, verticalOffset, left + width, verticalOffset + height); | ||||
|             left += width; | ||||
|         } | ||||
| @@ -68,15 +55,11 @@ public class HorizontalListView extends ListView { | ||||
|  | ||||
|     @Override | ||||
|     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { | ||||
|          | ||||
|         int newHeightMeasureSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); | ||||
|         //super.onMeasure(widthMeasureSpec, newHeightMeasureSpec); | ||||
|         int newWidthMeasureSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); | ||||
|         //LogUtils.d(TAG, String.format("newWidthMeasureSpec %d, newHeightMeasureSpec %d", newWidthMeasureSpec, newHeightMeasureSpec)); | ||||
|         super.onMeasure(newWidthMeasureSpec, newHeightMeasureSpec); | ||||
|          | ||||
| //        ViewGroup.LayoutParams params = getLayoutParams(); | ||||
| //        params.width = getMeasuredWidth(); | ||||
|     } | ||||
| } | ||||
|  | ||||
|   | ||||
							
								
								
									
										13
									
								
								libappbase/src/main/res/drawable/bg_border_round.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								libappbase/src/main/res/drawable/bg_border_round.xml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <shape xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     android:shape="rectangle"> | ||||
|     <stroke | ||||
|         android:width="1dp" | ||||
|         android:color="#000000" /> <!-- 这里可调整边框宽度和颜色 --> | ||||
|     <solid android:color="@android:color/transparent" /> | ||||
|     <corners  | ||||
|         android:bottomLeftRadius="6dip"  | ||||
|         android:bottomRightRadius="6dip"  | ||||
|         android:topLeftRadius="6dip"  | ||||
|         android:topRightRadius="6dip" />  | ||||
| </shape> | ||||
| @@ -10,8 +10,8 @@ | ||||
|         <shape android:shape="rectangle" >  | ||||
|             <gradient  | ||||
|                 android:angle="270"  | ||||
|                 android:endColor="#0F000000"  | ||||
|                 android:startColor="#0F000000" />  | ||||
|                 android:endColor="@color/colorAccent"  | ||||
|                 android:startColor="@color/colorAccent" />  | ||||
|             <corners  | ||||
|                 android:bottomLeftRadius="6dip"  | ||||
|                 android:bottomRightRadius="6dip"  | ||||
|   | ||||
| @@ -5,18 +5,18 @@ | ||||
| 	android:orientation="horizontal" | ||||
| 	android:layout_width="wrap_content" | ||||
| 	android:layout_height="match_parent" | ||||
| 	android:background="#FFEEEEEE"> | ||||
| 	android:background="@drawable/bg_border_round"> | ||||
|  | ||||
|     <TextView | ||||
|         android:layout_width="wrap_content" | ||||
|         android:layout_height="24dp" | ||||
|         android:layout_marginLeft="5dp" | ||||
|         android:id="@+id/viewlogtagTextView1"/> | ||||
| 	<TextView | ||||
| 		android:layout_width="wrap_content" | ||||
| 		android:layout_height="@dimen/button_height" | ||||
| 		android:layout_marginLeft="5dp" | ||||
| 		android:id="@+id/viewlogtagTextView1"/> | ||||
|  | ||||
|     <CheckBox | ||||
|         android:layout_width="wrap_content" | ||||
|         android:layout_height="24dp" | ||||
|         android:id="@+id/viewlogtagCheckBox1"/> | ||||
| 	<CheckBox | ||||
| 		android:layout_width="wrap_content" | ||||
| 		android:layout_height="@dimen/button_height" | ||||
| 		android:id="@+id/viewlogtagCheckBox1"/> | ||||
|  | ||||
| </LinearLayout> | ||||
|  | ||||
|   | ||||
| @@ -72,27 +72,29 @@ | ||||
| 		android:layout_below="@+id/viewlogRelativeLayoutToolbar" | ||||
| 		android:id="@+id/viewlogLinearLayout1" | ||||
| 		android:gravity="center_vertical" | ||||
| 		android:background="#FFC0F4C2"> | ||||
| 		android:background="@drawable/bg_shadow"> | ||||
|  | ||||
| 		<CheckBox | ||||
| 			android:layout_width="wrap_content" | ||||
| 			android:layout_height="wrap_content" | ||||
| 			android:layout_height="@dimen/button_height" | ||||
| 			android:text="ALL" | ||||
| 			android:id="@+id/viewlogCheckBox1"/> | ||||
| 			android:id="@+id/viewlogCheckBox1" | ||||
| 			android:background="@drawable/bg_border_round" | ||||
| 			android:layout_marginLeft="5dp" | ||||
| 			android:layout_marginRight="5dp"/> | ||||
|  | ||||
| 		<HorizontalScrollView | ||||
| 			android:layout_width="0dp" | ||||
| 			android:layout_height="match_parent" | ||||
| 			android:background="@drawable/bg_border" | ||||
| 			android:scrollbars="none" | ||||
| 			android:layout_weight="1.0" | ||||
| 			android:background="#FF97F2E3"> | ||||
| 			android:padding="5dp" | ||||
| 			android:layout_weight="1.0"> | ||||
|  | ||||
| 			<cc.winboll.studio.libappbase.views.HorizontalListView | ||||
| 				android:layout_width="wrap_content" | ||||
| 				android:layout_height="match_parent" | ||||
| 				android:background="@drawable/view_border" | ||||
| 				android:id="@+id/tags_listview" | ||||
| 				android:paddingLeft="10dp"/> | ||||
| 				android:id="@+id/tags_listview"/> | ||||
|  | ||||
| 		</HorizontalScrollView> | ||||
|  | ||||
|   | ||||
							
								
								
									
										9
									
								
								libappbase/src/main/res/values/dimens.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								libappbase/src/main/res/values/dimens.xml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <resources> | ||||
|     <!-- 定义一个名为text_size_normal的尺寸,值为16sp --> | ||||
|     <dimen name="text_size_normal">16sp</dimen> | ||||
|     <!-- 定义一个名为margin_small的尺寸,值为8dp --> | ||||
|     <dimen name="margin_small">8dp</dimen> | ||||
|     <!-- 定义一个名为image_width的尺寸,值为200dp --> | ||||
|     <dimen name="button_height">24dp</dimen> | ||||
| </resources> | ||||
		Reference in New Issue
	
	Block a user
	 ZhanGSKen
					ZhanGSKen