我正在尝试制作一个圆形的图像视图,但我得到一个不正确的输出.我正在附上照片
这些是用于此的xml文件
circle.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadius="0dp"
android:shape="ring"
android:thicknessRatio="1.9"
android:useLevel="false" >
<solid android:color="@android:color/transparent" />
<stroke
android:width="10dp"
android:color="@android:color/white" />
</shape>
Run Code Online (Sandbox Code Playgroud)
img.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/circle"/>
<item android:drawable="@drawable/ic_add_photo"/>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
图像视图是:
<ImageView
android:id="@+id/iv_dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/iv_person"
android:layout_below="@+id/iv_person"
android:layout_marginTop="37dp"
android:adjustViewBounds="true"
android:background="@drawable/img"
android:cropToPadding="true" />
Run Code Online (Sandbox Code Playgroud) 当我们想在Android中更改EditText的宽度时,我们使用以下代码行:
int px =(int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,200,r.getDisplayMetrics());
有人可以解释这是如何工作的,TypedValue.COMPLEX_UNIT_DIP返回什么?
我正在向片段中的操作栏添加制表符.但是当我尝试启动该片段时,我的应用程序在抛出空指针异常后崩溃
这是错误
Home.java文件是这样的:
public class Home extends Fragment implements ActionBar.TabListener {
private ViewPager viewPager;
private TabPagerAdapter tabPagerAdapter;
private ActionBar actionBar;
private FragmentActivity fragmentActivity;
private String[] tabs ;
public Home() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.fragment_home,container,false);
fragmentActivity = new FragmentActivity();
tabs = getResources().getStringArray(R.array.hometabs);
viewPager = (ViewPager)rootView.findViewById(R.id.pager);
actionBar = fragmentActivity.getActionBar();
tabPagerAdapter = new TabPagerAdapter(fragmentActivity.getSupportFragmentManager());
viewPager.setAdapter(tabPagerAdapter);
actionBar.setHomeButtonEnabled(false);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
for(String tab_name: tabs){ …Run Code Online (Sandbox Code Playgroud)