feat(ui): default dimension dp
This commit is contained in:
@@ -45,7 +45,7 @@ function showRegisterUI(){
|
|||||||
</linear>
|
</linear>
|
||||||
<linear>
|
<linear>
|
||||||
<text w="56" gravity="center" color="#111111" size="16">邮箱</text>
|
<text w="56" gravity="center" color="#111111" size="16">邮箱</text>
|
||||||
<input w="*" h="40" inputType="email"/>
|
<input w="*" h="40" inputType="textEmailAddress"/>
|
||||||
</linear>
|
</linear>
|
||||||
<linear gravity="center">
|
<linear gravity="center">
|
||||||
<button>确定</button>
|
<button>确定</button>
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public class Dimensions {
|
|||||||
if (!m.matches()) {
|
if (!m.matches()) {
|
||||||
throw new InflateException("dimension cannot be resolved: " + dimension);
|
throw new InflateException("dimension cannot be resolved: " + dimension);
|
||||||
}
|
}
|
||||||
int unit = m.groupCount() == 2 ? UNITS.get(m.group(2)) : TypedValue.COMPLEX_UNIT_PX;
|
int unit = m.groupCount() == 2 ? UNITS.getOr(m.group(2), TypedValue.COMPLEX_UNIT_DIP) : TypedValue.COMPLEX_UNIT_DIP;
|
||||||
float value = Integer.valueOf(m.group(1));
|
float value = Integer.valueOf(m.group(1));
|
||||||
return TypedValue.applyDimension(unit, value, context.getResources().getDisplayMetrics());
|
return TypedValue.applyDimension(unit, value, context.getResources().getDisplayMetrics());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,15 @@ public class ValueMapper<V> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public V getOr(String key, V defValue) {
|
||||||
|
V v = mHashMap.get(key);
|
||||||
|
if (v == null) {
|
||||||
|
return defValue;
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
public V get(String key) {
|
public V get(String key) {
|
||||||
V v = mHashMap.get(key);
|
V v = mHashMap.get(key);
|
||||||
if (v == null) {
|
if (v == null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user