小编tan*_*ana的帖子

Angular-chart.js - 使折线图不弯曲

我正在使用Angular-Chart.js的折线图指令(在https://jtblin.github.io/angular-chart.js/#line-chart).

正如您在上面的链接中看到的,折线图是曲线.我不想要曲线,我喜欢直线.如何配置折线图以使其不弯曲.非常感谢你.

angularjs chart.js angular-chart

6
推荐指数
1
解决办法
3206
查看次数

如何以编程方式为视图设置特定的宽度/高度?

我在xml布局文件中有一个布局.
在运行时,我想创建2个文本视图,然后添加到布局中.
=>我无法通过特定大小为2文本视图设置宽度/高度.
如果我设置MATCH_PARENT,那没关系.
如果我按任何特定尺寸设置,它只是WRAP_CONTENT

XML布局文件:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.androidsnipcode.MainActivity$PlaceholderFragment"
    android:orientation="vertical"
    android:id="@+id/mylayout">
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)


Dimens.xml:

<resources>
    <!-- Default screen margins, per the Android Design guidelines. -->
    <dimen name="activity_horizontal_margin">16dp</dimen>
    <dimen name="activity_vertical_margin">16dp</dimen>
    <dimen name="heigh">300dip</dimen>
    <dimen name="width">600dip</dimen>
</resources>
Run Code Online (Sandbox Code Playgroud)

Activity.java的onCreate():

LinearLayout layout = (LinearLayout) findViewById(R.id.mylayout);

        LinearLayout.LayoutParams layoutparams1 = new LinearLayout.LayoutParams(
                LayoutParams.MATCH_PARENT, R.dimen.heigh);
        TextView tv = new TextView(this);
        tv.setLayoutParams(layoutparams1);
        tv.setText("hello 1");
        tv.setBackgroundColor(Color.CYAN);
        layout.addView(tv);

        LinearLayout.LayoutParams layoutparams2 = new LinearLayout.LayoutParams(
                R.dimen.width, LayoutParams.MATCH_PARENT);
        TextView tv2 = new TextView(this);
        tv2.setLayoutParams(layoutparams2);
        tv2.setText("hello 2");
        tv2.setBackgroundColor(Color.MAGENTA);
        layout.addView(tv2);
Run Code Online (Sandbox Code Playgroud)

屏幕截图:第一个textview的高度和第二个textview的宽度不符合我的预期(它的包装内容不是我特定的大小)
第一个textview的高度和第二个textview的宽度不符合我的预期

android android-layout

2
推荐指数
1
解决办法
9101
查看次数