小编Joj*_*ojo的帖子

Android Studio中的Assets文件夹?

我试图使用自定义字体,我读过我想将字体放在资产/字体中.我正在使用Android Studio,似乎我没有资产文件夹.所以我创建了一个.但是当我将assets文件夹放在src/main中时,我的应用程序崩溃了.我使用此代码加载我的字体.

Typeface fontRegular = Typeface.createFromAsset(getAssets(), "fonts/DroidSans.ttf");
Typeface fontBold = Typeface.createFromAsset(getAssets(), "fonts/DroidSans-Bold.ttf");

myDeviceModelTxt.setTypeface(fontRegular);
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

android custom-font typeface android-studio

24
推荐指数
2
解决办法
3万
查看次数

如何添加将View扩展到主要活动的自定义类?

我在向主要活动添加自定义类时遇到问题.

我的自定义类中的代码:

public class DetailView extends View {

    public DetailView(Context context) {
        super(context);

        this.setBackgroundColor(0xFF00FF00 );



    }
}
Run Code Online (Sandbox Code Playgroud)

主要活动中的代码:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


    linearLayout = (LinearLayout) findViewById(R.id.linearLayout1);

    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    linearLayout.setOrientation(LinearLayout.VERTICAL);


    txt = new TextView(this);
    txt.setText("hello");
    txt.setId(6);
    txt.setLayoutParams(params);
    linearLayout.addView(txt);

    DetailView detailView = new DetailView(this.getApplicationContext());
    linearLayout.addView(detailView);

}
Run Code Online (Sandbox Code Playgroud)

为什么不能看到detailView?我是Android开发的新手,所以我需要任何帮助,或者一些好的链接或任何东西.谢谢

java android

7
推荐指数
1
解决办法
4893
查看次数

当我在iOS 7中关闭模态视图时,为什么我的导航栏会暂时消失?

当我从我的模态视图控制器返回到我的主视图控制器(我有一个水平动画)时,我的主控制器导航栏自身有点太高而不能快速秒,然后跳回到正确的位置.有人知道为什么吗?我一直在谷歌搜索它,但没有成功.

应用代表:

 [navigationController.navigationBar setBarTintColor: [UIColor whiteColor]];
 [navigationController.navigationBar setTranslucent: NO];
Run Code Online (Sandbox Code Playgroud)

当我按下按钮打开我的信息视图时:

UIViewController *infoViewController;
infoViewController = [[InfoViewController alloc] initWithNibName:@"InfoViewController" bundle: nil];
infoViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController: infoViewController animated: YES completion:nil];
Run Code Online (Sandbox Code Playgroud)

我没有在任何xib文件上使用自动布局.我的主视图控制器xib文件为空,状态栏:默认.我的信息视图控制器xib文件中有一些东西.

关闭模态视图控制器的代码:

-(IBAction)onBackBtnClick:(id)sender
{
    [self dismissModalViewControllerAnimated: YES];
}
Run Code Online (Sandbox Code Playgroud)

objective-c uinavigationbar ios7

5
推荐指数
1
解决办法
1548
查看次数