Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_vedio
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
android
android_vedio
Commits
003e5176
Commit
003e5176
authored
Jan 09, 2024
by
mengcuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码优化
parent
3353f548
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
9 deletions
+25
-9
UIUtils.java
...pp/src/main/java/com/duben/xixiplaylet/utils/UIUtils.java
+24
-8
item_empty_cash.xml
video/app/src/main/res/layout/item_empty_cash.xml
+1
-1
No files found.
video/app/src/main/java/com/duben/xixiplaylet/utils/UIUtils.java
View file @
003e5176
...
@@ -28,7 +28,7 @@ public class UIUtils {
...
@@ -28,7 +28,7 @@ public class UIUtils {
DisplayMetrics
dm
=
context
.
getResources
().
getDisplayMetrics
();
DisplayMetrics
dm
=
context
.
getResources
().
getDisplayMetrics
();
return
dm
.
widthPixels
;
return
dm
.
widthPixels
;
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
DisplayMetrics
dm
=
MintsApplication
.
getContext
().
getResources
().
getDisplayMetrics
();
DisplayMetrics
dm
=
ForegroundOrBackground
.
getTopActivity
().
getResources
().
getDisplayMetrics
();
return
dm
.
widthPixels
;
return
dm
.
widthPixels
;
}
}
...
@@ -39,7 +39,7 @@ public class UIUtils {
...
@@ -39,7 +39,7 @@ public class UIUtils {
DisplayMetrics
dm
=
context
.
getResources
().
getDisplayMetrics
();
DisplayMetrics
dm
=
context
.
getResources
().
getDisplayMetrics
();
return
dm
.
heightPixels
;
return
dm
.
heightPixels
;
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
DisplayMetrics
dm
=
MintsApplication
.
getContext
().
getResources
().
getDisplayMetrics
();
DisplayMetrics
dm
=
ForegroundOrBackground
.
getTopActivity
().
getResources
().
getDisplayMetrics
();
return
dm
.
heightPixels
;
return
dm
.
heightPixels
;
}
}
...
@@ -56,8 +56,13 @@ public class UIUtils {
...
@@ -56,8 +56,13 @@ public class UIUtils {
* 根据手机的分辨率从 dp 的单位 转成为 px(像素)
* 根据手机的分辨率从 dp 的单位 转成为 px(像素)
*/
*/
public
static
int
dip2px
(
Context
context
,
float
dpValue
)
{
public
static
int
dip2px
(
Context
context
,
float
dpValue
)
{
final
float
scale
=
context
.
getResources
().
getDisplayMetrics
().
density
;
try
{
return
(
int
)
(
dpValue
*
scale
+
0.5f
);
final
float
scale
=
context
.
getResources
().
getDisplayMetrics
().
density
;
return
(
int
)
(
dpValue
*
scale
+
0.5f
);
}
catch
(
Exception
e
){
final
float
scale
=
ForegroundOrBackground
.
getTopActivity
().
getResources
().
getDisplayMetrics
().
density
;
return
(
int
)
(
dpValue
*
scale
+
0.5f
);
}
}
}
...
@@ -284,13 +289,24 @@ public class UIUtils {
...
@@ -284,13 +289,24 @@ public class UIUtils {
}
}
public
static
int
px2dip
(
Context
context
,
float
pxValue
)
{
public
static
int
px2dip
(
Context
context
,
float
pxValue
)
{
final
float
scale
=
context
.
getResources
().
getDisplayMetrics
().
density
;
try
{
return
(
int
)
(
pxValue
/
(
scale
<=
0
?
1
:
scale
)
+
0.5f
);
final
float
scale
=
context
.
getResources
().
getDisplayMetrics
().
density
;
return
(
int
)
(
pxValue
/
(
scale
<=
0
?
1
:
scale
)
+
0.5f
);
}
catch
(
Exception
e
){
final
float
scale
=
ForegroundOrBackground
.
getTopActivity
().
getResources
().
getDisplayMetrics
().
density
;
return
(
int
)
(
pxValue
/
(
scale
<=
0
?
1
:
scale
)
+
0.5f
);
}
}
}
public
static
int
dp2px
(
Context
context
,
float
dp
)
{
public
static
int
dp2px
(
Context
context
,
float
dp
)
{
final
float
scale
=
context
.
getResources
().
getDisplayMetrics
().
density
;
try
{
return
(
int
)
(
dp
*
scale
+
0.5f
);
final
float
scale
=
context
.
getResources
().
getDisplayMetrics
().
density
;
return
(
int
)
(
dp
*
scale
+
0.5f
);
}
catch
(
Exception
e
){
final
float
scale
=
ForegroundOrBackground
.
getTopActivity
().
getResources
().
getDisplayMetrics
().
density
;
return
(
int
)
(
dp
*
scale
+
0.5f
);
}
}
}
public
static
float
getDensity
(
Context
context
)
{
public
static
float
getDensity
(
Context
context
)
{
...
...
video/app/src/main/res/layout/item_empty_cash.xml
View file @
003e5176
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
android:layout_centerHorizontal=
"true"
android:layout_centerHorizontal=
"true"
android:layout_gravity=
"center|center_horizontal"
android:layout_gravity=
"center|center_horizontal"
android:paddingTop=
"37dp"
android:paddingTop=
"37dp"
android:text=
"
您还没有订单哦
"
android:text=
"
还没有数据哦~
"
android:textColor=
"#7F7F7F"
android:textColor=
"#7F7F7F"
android:textSize=
"18sp"
/>
android:textSize=
"18sp"
/>
</RelativeLayout>
</RelativeLayout>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment